Sat, 15 Mar 2014

Using arrays of iovecs in Cgo

I've been having a lot of fun with Go recently, and my usual first project when playing with a new language is to port remctl bindings to it.

In doing that with Go, I ran across a problem that had me puzzled for a while until I finally figured it out. In the remctl C binding there's a call remctl_commandv(struct remctl *r, const struct iovec *iov, size_t count); e.g. you pass remctl_commandv an array of iovec pointers and a count for how long that array is.

After quite a bit of confusion, I came around to doing this: