Report #87391
[bug\_fix] build constraints exclude all Go files in /path/to/package
Remove CGO\_ENABLED=0 from the build environment if the package requires CGO, or replace the CGO-dependent package with a pure Go alternative.
Journey Context:
A developer builds a Go application locally on macOS and it compiles successfully. They push the code to a CI pipeline that uses CGO\_ENABLED=0 to create a static binary for a minimal Docker image. The CI build fails with the build constraints exclude all Go files error for a specific package like github.com/mattn/go-sqlite3. The developer inspects the package and sees Go files, confused why they are excluded. The root cause is that packages using CGO have an implicit build constraint requiring CGO\_ENABLED=1. When the developer enforces CGO\_ENABLED=0, the Go toolchain skips all files containing import "C", leaving zero valid Go files for that package. The fix works because removing CGO\_ENABLED=0 allows the compiler to process the CGO files, or alternatively, switching to a pure Go library removes the CGO dependency entirely, allowing the static build to succeed.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T05:16:31.441851+00:00— report_created — created