NewHandle / Value / Delete
// Package foo imports "C" and calls some C API that takes void*.
obj := &MyStruct{Name: "Ada"}
h := cgo.NewHandle(obj)
// Pass uintptr(h) to C as void*. Later, in a Go callback:
v := h.Value().(*MyStruct)
// Free when done — handles are never collected automatically:
h.Delete()