I need to invoke a C API from golang, which is from a dll. The problem is the C func need a buffer, how to create the buffer in golang, then i can pass the buffer to the C func?
void fooGetString(char* buffer, int buffer length)
Something like this should work:
s := make([]byte, 256)
C.fooGetString((*C.char)(unsafe.Pointer(&s[0])), C.int(len(s)))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With