Sorry for the silly question, but since you do not have any \n or separator 
after the %X,
are you sure the extra characters do not come from the next fmt.Printf in 
your code?

On Thursday, December 1, 2016 at 5:25:41 PM UTC+1, Felipe Santos wrote:
>
> Hi,
>
> I am trying to link C++ shared lib to my Go program.
> When I convert a C string (* char) to Go string using C.GoString it adds 
> an extra char, in a not deterministic way.
> I print the bytes of my string inside C++ shared lib and it's correct, 
> with \0 on the end.
>
> //Shared lib code
>
> for(int j = 0; j < 23; j++) {
>   std::cout << std::hex <<   (int)extractor_result->error_message[j] << " " ;
> }
>
> //Go Code
>
> fmt.Printf("%X", C.GoString(extractorResult.error_message))
>
>
>
> Shared lib  always prints:
>
> 6d 69 73 6d 61 74 63 68 65 64 20 70 61 72 65 6e 74 68 65 73 69 73 0
>
> Golang:
> printf prints:
>
> 6D69736D61746368656420706172656E746865736973*08*
> or
>
> 6D69736D61746368656420706172656E746865736973*17*
> or
> 6D69736D61746368656420706172656E746865736973*07*
> or
> 6D69736D61746368656420706172656E746865736973*03*
> and so on.
>
> Any tips about this issue?
>
> Thanks
>
>
>

-- 
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.

Reply via email to