Re: [go-nuts] Passing []byte from golang to char * C.

2017-06-14 Thread Aditi Bhiwaniwala
the error occur because there is 0 in my byte array . Do i need to encode it then? On Wed, Jun 14, 2017 at 9:16 PM, andrey mirtchovski wrote: > can you show us a complete example with a stub C function? in > particular the conversion to (*C.char) from unsafe.Pointer(&data[0]) > should work. comp

[go-nuts] Passing []byte from golang to char * C.

2017-06-14 Thread aditi . bhiwaniwala
I have a byte array of image in golang , i have to pass this array to my C function as char* . I did he following , data, err := ioutil.ReadAll(out.Body) str := fmt.Sprintf("%s",data) s:=C.main1(C.CString(str)) s:=C.main1((*C.char)(unsafe.Pointer(&data[0]))) but