On Thu, Aug 29, 2019 at 6:26 PM George Hartzell <hartz...@alerce.com> wrote: > > I suppose I *could* write a cgo library that would wrap the C-based > [i2c-tools] library, but I wanted to do it directly in Go, without > adding the [i2c-tools] dependency. > > Or, are you saying that I should create a package that does the > `import "C"` and `import "unsafe"` and then somehow uses "C.Ioctl" (or > something, I haven't dug very far into this line of thought yet...) to > make the call into the kernel. I can see how every time such a thing > was built it would use that Go version's latest/greatest understanding > of how to map the Go and C structures, whereas the approach I'm > copying is static and might become out of date. But, in that case, > why do the things in golang.org/x/sys exist (though they're probably > built for each release and are therefor up-to-date by def'n)?
There is another approach, which is to use import "C", and then write code like const IoctlConstant = C.IoctlConstant type GoIoctlType = C.CIoctlType and then use those types in code that calls unix.Syscall(SYS_IOCTL, IoctlConstant, &GoIoctlType{value}). 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. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAOyqgcWmKCpXd%2BfmG68116UYvZ4OG8nb-8sQvEXhXiqukbcbJw%40mail.gmail.com.