First, cast valFromSystem
into an unsafe.Pointer
. An unsafe.Pointer
can be casted into any pointer type. Next, cast the unsafe.Pointer
into a pointer to whatever type of data valFromSystem
points to, e.g. an uint64
.
ptrFromSystem = (*uint64)(unsafe.Pointer(valFromSystem))
If you just want to get the value of the pointer (without dereferencing it), you can use a direct cast:
uint64FromSystem = uint64(valFromSystem)
Though remember that you should use the type uintptr
when using pointers as integers.