On Thu, Dec 8, 2016 at 12:48 AM, Wanghb Wang <wangh...@gmail.com> wrote: > my C code Array for example: > const uint8_t** kPacketMaskRandomTbl[48] = { > kPacketMaskRandom1, > kPacketMaskRandom2, > kPacketMaskRandom3, > ..... > }; > const uint8_t* kPacketMaskRandom1[1] = { > kMaskRandom1_1 > }; > const uint8_t kMaskRandom1_1[2] = { > 0x80, 0x00 > }; > ..... > > > I want to read bytes from > kPacketMaskRandomTbl > by using cgo, How can I do? > > I write code like this > > qq := > ((*uint8)(unsafe.Pointer((uintptr((*uint8)(unsafe.Pointer(uintptr(unsafe.Pointer(p))+uintptr(1)))) > + uintptr((unsafe.Sizeof(*uint8))))))) > > It is not right! > How can I do?
The top level array should have the type of a Go array, but it's true that the inner levels will be pointer types, and of course Go, unlike C, does not permit array-style access for pointer types. I would suggest simply writing little helper functions in Go to do the array accessing using unsafe.Pointer. Ian -- 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.