You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But I get the following error: ./schnorr.go:39:43: cannot use key.pubkey.data[:] (type []_Ctype_uchar) as type []byte in argument to hex.EncodeToString
I can get this working by doing something like: return hex.EncodeToString(C.GoBytes(unsafe.Pointer(&key.pubkey.data[0]), C.int(len(key.pubkey.data))))
But it feels kinda stupid, it's a lot of complexity to convert an already go slice into another go slice just to replace the _Ctype_uchar type with byte type, and they are 100% compatible anyway.
Is there a better way to do this?
The text was updated successfully, but these errors were encountered:
Unlike many projects, we don't use the issue tracker for questions. You will get better and faster answers on a forum. Please see https://golang.org/wiki/Questions. Thanks.
I don't know of a better way to do this than what you are already done. The interface between Go and C is imperfect.
Hi,
First of all, cgo is pretty cool, thanks for that :)
I do have a question though, I have a lot of C structs that just contain a byte array, and I want to use the array in it as a
[]byte
. ie:I would like to be able to then do:
But I get the following error:
./schnorr.go:39:43: cannot use key.pubkey.data[:] (type []_Ctype_uchar) as type []byte in argument to hex.EncodeToString
I can get this working by doing something like:
return hex.EncodeToString(C.GoBytes(unsafe.Pointer(&key.pubkey.data[0]), C.int(len(key.pubkey.data))))
But it feels kinda stupid, it's a lot of complexity to convert an already go slice into another go slice just to replace the
_Ctype_uchar
type withbyte
type, and they are 100% compatible anyway.Is there a better way to do this?
The text was updated successfully, but these errors were encountered: