Cgo is a library that is built into the standard library of Go that allows users to invoke calls to underlying C programs in their Go code. Cgo is often used as a delegator for things that are currently coded in C but don't have equivalent Go code written.
Cgo should be used sparingly and only when there isn't an equivalent Go library available for a system. Cgo adds a few limitations to your Go programs:
- Needless complexity
- Difficulty troubleshooting
- Added complexity of building and compiling C code
- Much of Go's tooling is not available for use in Cgo programs
- Cross-compiling doesn't work as expected or at all
- The complexity of C code
- Native Go calls are much faster than Cgo calls
- Slower build times
If you can (or must) live with all of these stipulations, Cgo may be a necessary resource for the project that you're working...