Nothing new or special regarding Golang CGO. I have been exploring it lately and it took me some time to understand its deep aspects, mostly on passing Go callbacks to C. And I wanted to keep close some full examples.
I created a small repository on GitHub which shows interactions of Go code with a C library (included) by passing and/or receiving numbers, strings, byte arrays, structs, enums, and calling Go functions from the C library.
Sources of inspiration and learning:
- 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
See the GitHub repository with the CGO examples and compile the code yourself on your machine or inside the Docker environment you’ll find there.