func (s *VirSecret) GetUUIDString() (string, error) { var cUuid [C.VIR_UUID_STRING_BUFLEN](C.char) cuidPtr := unsafe.Pointer(&cUuid) result := C.virSecretGetUUIDString(s.ptr, (*C.char)(cuidPtr)) if result != 0 { return "", errors.New(GetLastError()) } return C.GoString((*C.char)(cuidPtr)), nil }
// UUID fetches the UUID of the secret. func (sec Secret) UUID() (string, error) { cUUID := (*C.char)(C.malloc(C.size_t(C.VIR_UUID_STRING_BUFLEN))) defer C.free(unsafe.Pointer(cUUID)) sec.log.Println("reading secret UUID...") cRet := C.virSecretGetUUIDString(sec.virSecret, cUUID) ret := int32(cRet) if ret == -1 { err := LastError() sec.log.Printf("an error occurred: %v\n", err) return "", err } uuid := C.GoString(cUUID) sec.log.Printf("UUID: %v\n", uuid) return uuid, nil }