I want to pass a uintptr to unsafe.Pointer but govet is telling me possible misuse of unsafe.Pointer. I can't figure out how to satisfy govet.
func Example(base uintptr) byte {
x := *(*byte)(unsafe.Add(base, 4))
return x
}
If i pass &base govet does to complain but breaks the functionality because it is passing the address of uintptr.
unsafe.Addtakes anunsafe.Pointeras its first argument, but you're passing it auintptr. It's not govet that complains, it's the go compiler, and here is the error:Instead:
As a complete program (although this program is probably unsound because the
aarray could in principle be garbage collected beforeExampleis called).