Thanks for your info, it seems that it's reporting the same error but still 
not have a solution.

After tried to use unsafe:

return (*C.struct_Media)(unsafe.Pointer(c_struct_media))


it reports same error:
panic: runtime error: cgo result has Go pointer

Any further insights about this issue? many thanks.

On Monday, March 20, 2017 at 9:43:38 PM UTC+8, Steven Hartland wrote:
>
> The following may help:
> http://feisky.xyz/2016/04/19/cgo-in-go-1-6/
>
> On 20/03/2017 13:25, Song Liu wrote:
>
> Hi, 
>
> I have a shared lib as bellow:
>
> /*
>
> #include <stdint.h>
>
>  struct Media {
>
>     char*    Name;
>
>     char*    Path;
>
>     uint64_t Size;
>
> };
>
> */
>
> import "C"
>
>  //export GetMediaFromDB
>
> func GetMediaFromDB(filename *C.char) *C.struct_Media {
>
>     c_struct_media := &C.struct_Media{}
>
>     return c_struct_media
>
> }
>
>
> Which is called in another program written by C, but when it's running it 
> report error:
>
> panic: runtime error: cgo result has Go pointer
>
> Could you help with the correct way to return a struct from Go ?
>
> Many thanks.
>
> Thanks,
> Song
> -- 
> 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...@googlegroups.com <javascript:>.
> For more options, visit https://groups.google.com/d/optout.
>
>
>

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