Hi, this is my first post an question regarding GO and CGO.
I need to store a GO reference in C. currently I use the following pseudo-code:
-
create a global map
var lockService = make(map[MyUUID]MyInterface)
(this is not thread-safe) -
save the MyUUID (which have the max length of a C-Pointer, 64bit) in C
var uid MyUUID = (generate)
C.MyUUIDset(uid)
lockService[uid] = MyInterfaceObject -
get my MyInterface back with:
uid := C.MyUUIDget()
lockService[uid].MyFunc()
Question: is there a go “builtin” to solve the “export-handle” problem?