How does golang create a buffer to pass to a C dll function?
go
Solution
Something like this should work:
s := make([]byte, 256)
C.fooGetString((*C.char)(unsafe.Pointer(&s[0])), C.int(len(s)))
Problem
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) ```