Mischiefblog
I make apps for other people

Posts made on Thursday, June 26th, 2014

Example cgo (Golang) app that calls a native library with a C structure

Posted by Chris Jones
On June 26th, 2014 at 12:47

Permalink | Trackback | Links In |

Comments Off on Example cgo (Golang) app that calls a native library with a C structure
Posted in General

Here’s a sample Go application that calls a native library. This uses cgo to link to the native library, pass a pointer to a C structure to a native function, and does it all from Go.

This example includes:

  • a Go main
  • a Go package
  • a static C library (shared libraries on OS X require tweaks to dyld)
  • instructions for compilation

(more…)