Report #50567
[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 on the system. Alternatively, if using Docker, switch from the \`alpine\` or \`scratch\` base images to one with build tools like \`golang:1.X\` or install \`build-base\`/\`gcc\`.
Journey Context:
A developer builds a Go application locally on macOS/Windows and it works fine. They push it, and the CI pipeline \(which uses a minimal Docker image like \`golang:alpine\`\) fails with this error on a dependency like \`go-sqlite3\`. They dig into the dependency and find files with \`import "C"\` and the \`cgo\` build tag. By default, Go builds with CGO enabled if a C compiler is found. The minimal Alpine image lacks \`gcc\`. When Go can't find a C compiler, it implicitly disables CGO, which causes all \`.go\` files requiring CGO to be excluded by the build constraints. If all files in the package require CGO, the 'exclude all Go files' error occurs. Setting \`CGO\_ENABLED=1\` explicitly and installing \`gcc\` provides the necessary toolchain.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T15:21:41.860644+00:00— report_created — created