Cgo - safe a reference to a go object - "export-handle" problem

I think your solution, generating handles yourself and passing them to C instead of Go pointers, is about as good as it gets.