Well i did some something like this, seems to be working
arr := make([]*C.char, count_emp) for i, s := range arr { cs := C.CString(C.GoString(s)) defer C.free(unsafe.Pointer(cs)) arr[i] = cs } k = (C.ushort)(C.FetchName_Emp(C.int(val),&arr[0])) On Friday, 29 March 2019 09:23:31 UTC+5:30, Justin Israel wrote: > > > > On Friday, March 29, 2019 at 11:08:06 AM UTC+13, Ashutosh Baghel wrote: >> >> Hi folks, >> >> I am new to Go-Programming and having the following requirement, I need >> to have Array of Strings,(for example names) at my 'Go Side' . >> >> But i would get this names from my C library API which i have included in >> my Go program. >> >> Note: I have liberty to modify the C library too, i could control the >> return type. >> >> Please help with this. >> > > Here is an example from one of my projects using cgo as a binding to a C++ > library: > > C string array to Go > https://github.com/justinfx/openimageigo/blob/master/imagespec.go#L387 > > Go string slice to C > https://github.com/justinfx/openimageigo/blob/master/imagespec.go#L402 > > There are other approaches besides this one. > > > >> > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.