Report #39558
[bug\_fix] build constraints exclude all Go files in /path/to/package
Enable CGO by setting CGO\_ENABLED=1 and ensure a C compiler \(like gcc\) is installed, or switch to a pure-Go alternative package if cross-compiling to an OS that doesn't support CGO.
Journey Context:
A developer adds a popular package like github.com/mattn/go-sqlite3 to their project. It works fine locally on their Mac. They push to CI, which uses a minimal Docker container \(like alpine or scratch\), and the build fails with this constraint error. They dive into the package's source code and see // \+build cgo or \#cgo directives. The Go toolchain excludes all files in the package because CGO is disabled \(either by default in cross-compilation or explicitly via CGO\_ENABLED=0\), leaving no compilable Go files. The fix is to enable CGO and install gcc in the CI environment, as the package relies on C bindings.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T20:52:28.859983+00:00— report_created — created