My project could benefit from some cgo code, but I have a fallback implementation in go to use when cgo is not available during build.
However, when I build without cgo, I get the error C source files not allowed when not using cgo or SWIG
.
The C code is only used in a file marked with // +build cgo
and there is an alternative available with // +build !cgo
.
How do I set things up so I can build with cgo where available, but also keep supporting the fallback behaviour?
FWIW, the code is at https://github.com/raboof/connbeat/tree/tcp_diag and the error can be triggered with a 'make crosscompile'.