type Foo struct { procAddr uintptr}
func (f Foo) ProcAddr() uintptr { return f.procAddr}
func Bar() Foo {
return Foo{C.SomeFunc()}
}
p := C.ASDF(unsafe.Pointer(A.Bar().ProcAddr())) // possible misuse of unsafe.Pointer
Why not just pass the C pointer from one package to another?
Cgo translates C types into equivalent unexported Go types. Because the translations are unexported, a Go package should not expose C types in its exported API: a C type used in one Go package is different from the same C type used in another.
Or an unsafe.Pointer?
Make procAddr a *byte
These types are uintptr on the Go side because they would otherwise confuse the Go garbage collector; they are sometimes not really pointers but data structures encoded in a pointer type. All operations on these types must happen in C. The proper constant to initialize an empty such reference is 0, not nil.