github.com/itsabgr/go-handy@v0.0.0-20220724000257-022d51f2b9c6/pointer.go (about) 1 package handy 2 3 import "unsafe" 4 5 //Ref returns a uintptr points to the value 6 func Ref[T any](value *T) uintptr { 7 return uintptr(unsafe.Pointer(value)) 8 } 9 10 //DeRef returns the value pointer points to 11 func DeRef[T any](ptr uintptr) T { 12 return *((*T)(unsafe.Pointer(ptr))) 13 }