Re: [go-nuts] cgo style question

2017-11-03 Thread 'Bryan Mills' via golang-nuts
I have argued that there ought to be a standard function for this. There is a proposal to add a simpler API for manipulating slice headers directly, but it is labeled Go 2. In the meantime, see this comment

Re: [go-nuts] cgo style question

2017-11-03 Thread Andy Balholm
Use the arr1 style when the length of the C array is known at compile time, and the arr2 style when it’s not known till runtime. Andy > On Nov 3, 2017, at 9:18 AM, DV wrote: > > Which "style" of wrapping a C array in a Go slice is more idiomatic in this > code - https://play.golang.org/p/6EbK

[go-nuts] cgo style question

2017-11-03 Thread DV
Which "style" of wrapping a C array in a Go slice is more idiomatic in this code - https://play.golang.org/p/6EbKl22MPQ - "arr1" or "arr2"? They both seem to produce the exact same result. I've seen the "arr2" style more often, but I don't understand why. The way I wrapped "arr1" seems more cle