FAQ
I am facing the same issue.
1) bps := make([]_Ctype_T32_Breakpoint, max)
2) bps := make([]C.struct_T32_Breakpoint, max)
The first method works, the second method will produce type of [0]byte.
So for my project, I use the first method to resolve the error. And when
need to use the pointer, use
(*_Ctype_T32_Breakpoint)(unsafe.Pointer(&bps[0]))
to cast to c structure pointer.

Don't understand the difference by using _Ctype_T32_Breakpoint and
C.struct_T32_Breakpoint to refer to same C struct.
On Tuesday, 12 June 2012 08:47:55 UTC+8, Andrew Gallant wrote:

You can unsafe type convert to get the fields you need.
How? I understand how to do it with a Go type:

(*someGoType)(someUnsafePointer)

but in my case, "someGoType" is actually a C type whose translation to
Go is simply *[0]byte. So that

(*C.struct_wl_display)(someStruct)

won't do anything. In fact, this is the important bit in my first
pasty:

var disp *C.struct_wl_display
fmt.Printf("Type: %T\n", disp)

Where the output is "*uint8[0]". The godefs are:

var disp *[0]byte
fmt.Printf("Type: %T\n", disp)

The key here is that I'm already telling Go that 'disp' is a
*C.struct_wl_display. So what am I going to use to convert a *uint8[0]
to a *C.struct_wl_display if *C.struct_wl_display is itself a
*uint8[0]?

Using something like 'type blahblah C.struct_wl_display' doesn't work
either, and is translated to 'type blahblah [0]byte'.
Thanks for the feedback on biogo. You may be interested in boom if you're
doing bioinfo work. Also, please have a look at the API for the exp
packages - they are way too bloated for my liking, but I'm too close to
them to really be sure, so feedback there would be appreciated.
I'm going to be diving back into my research project tomorrow, so
hopefully I'll get chance to take a look at the exp packages. I'll see
if I can come up with any feedback. (The piece I'm interested in now
is your Smith-Waterman alignment implementation, which is beautifully
written.)

- Andrew
--

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedJan 23, '13 at 6:09a
activeJan 23, '13 at 6:09a
posts1
users1
websitegolang.org

1 user in discussion

Me Zhuyong: 1 post

People

Translate

site design / logo © 2022 Grokbase