Re: [go-nuts] Convert *C.char to array of strings in Go

2019-05-01 Thread Justin Israel
On Wed, May 1, 2019, 11:44 PM Nitish Saboo wrote: > Hi Jusitn, > > I realised I have value_len field in my arguments.I did this : > > func Nitish(key *C.char, value *C.char, value_len C.size_t){ > > f.WriteString(C.GoString(key)+ ":") > s := C.GoStringN(value, C.int(value_len)) >

Re: [go-nuts] Convert *C.char to array of strings in Go

2019-05-01 Thread Nitish Saboo
Hi Jusitn, I realised I have value_len field in my arguments.I did this : func Nitish(key *C.char, value *C.char, value_len C.size_t){ f.WriteString(C.GoString(key)+ ":") s := C.GoStringN(value, C.int(value_len)) //fmt.Println(s) f.WriteString(s) f.WriteString("\n") } Am I doing it correctly?

Re: [go-nuts] Convert *C.char to array of strings in Go

2019-05-01 Thread Justin Israel
On Wed, May 1, 2019 at 9:40 PM Nitish Saboo wrote: > Actually, this is what is happening: > > func Nitish(key *C.char, value *C.char, value_len C.size_t){ > >f.WriteString(C.GoString(key)+ ":") >f.WriteString(C.GoString(value)) >f.WriteString("\n") > > } > > This callback method is

Re: [go-nuts] Convert *C.char to array of strings in Go

2019-05-01 Thread Nitish Saboo
Actually, this is what is happening: func Nitish(key *C.char, value *C.char, value_len C.size_t){ f.WriteString(C.GoString(key)+ ":") f.WriteString(C.GoString(value)) f.WriteString("\n") } This callback method is getting called from C code multiple times. I am planning to write the

Re: [go-nuts] Convert *C.char to array of strings in Go

2019-04-30 Thread Nitish Saboo
Hi, I have this method: func CallBack(key *C.char, value *C.char, value_len C.size_t){ } and the *value* parameter in the arguments is containing the given string 'Fp5PpR2roT6uPnte47 image/gif'. I want to extract only first word from the string.Let me know how can I do this. I don't

Re: [go-nuts] Convert *C.char to array of strings in Go

2019-04-30 Thread Justin Israel
On Wednesday, May 1, 2019 at 7:06:47 AM UTC+12, Nitish Saboo wrote: > > Apologies.I did this 'strings.Split(C.GoString(*C.char),""). > I am getting 'Incompatible types' compilation error. > Are you literally doing this? strings.Split(C.GoString(*C.char),"") Something like this should be

Re: [go-nuts] Convert *C.char to array of strings in Go

2019-04-30 Thread Nitish Saboo
Apologies.I did this 'strings.Split(C.GoString(*C.char),""). I am getting 'Incompatible types' compilation error. Thanks On Wed, May 1, 2019 at 12:30 AM Nitish Saboo wrote: > Hi, > > I want to convert *C.char to array of strings in Go. > I want to do this because I want the first word from

[go-nuts] Convert *C.char to array of strings in Go

2019-04-30 Thread Nitish Saboo
Hi, I want to convert *C.char to array of strings in Go. I want to do this because I want the first word from the string.Strings are getting appended to *C.char and I want the first word of the string. I am doing it using 'strings.Split(C.GoString(*C.char))[0]', but it is giving error. Can