On Monday, December 3, 2018 at 12:02:07 AM UTC-5, Ian Lance Taylor wrote:
>
> On Sat, Dec 1, 2018 at 9:39 AM <leeo...@gmail.com <javascript:>> wrote: 
> > 
> > I am using swig wrap a c++ module , the generated go code is like this: 
> > 
> > type  MediaFrame interface { 
> >      GetLength()  uint 
> >      GetData()  (*byte) 
> > } 
> > 
> > I want to convert the *byte  to []byte,  How to do this? 
>
> One approach is 
>
> s := 
> (*[1<<30]byte)(unsafe.Pointer(mf.GetData())[:mf.GetLength():mf.GetLength()] 
>
> Ian 
>

If you need to handle slices larger than 2³⁰ bytes, a more robust version 
of this same approach is described 
in https://golang.org/issue/13656#issuecomment-303216308.
 

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