I have some c code that look like this-
*((Oid *) ((char *)(tup)
where Oid is a uint32 type and tup is a struct. I want to convert it to go lang. I have decoded the struct but not able to figure out how to convert above line to go lang.
The Go equivalent to a casting a C pointer is converting a pointer to an unsafe.Pointer
, which can then be converted to a pointer of any type you wish.
If tup
is a pointer to a struct in C, you could convert it to a *uint32
like so:
u := (*uint32)(unsafe.Pointer(C.tup))