How do I use Go's "foreign function interface" to call out to a C function?
This interface is mentioned on the FAQ, but I cannot see it mentioned elsewhere in the docs.
Check out this file from the Go repository. It shows how to wrap a C library in Go and has quite a few comments that explain the process.
Here is an article that demonstrates the following with Cgo:
To lead with an example, here's a Go package that provides two functions -
Random
andSeed
- that wrap C'srand
andsrand
functions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With