cgo-examples icon indicating copy to clipboard operation
cgo-examples copied to clipboard

Examples of calling C code from Go

CGO Examples

Examples of calling C code from Go (including a test C library). Passing and getting numbers, strings, enums, structs, callbacks.

Build and run Docker env

make env

Compile and run app

make

See Makefile

Docs

  • https://golang.org/cmd/cgo/
  • https://blog.golang.org/c-go-cgo
  • https://github.com/golang/go/wiki/cgo
  • https://gist.github.com/zchee/b9c99695463d8902cd33
  • https://dev.to/mattn/call-go-function-from-c-function-1n3