Report #25357
[bug\_fix] build constraints exclude all Go files in /path/to/package
Ensure the target OS/Architecture matches the build tags, or if the package requires CGO, enable it by setting \`CGO\_ENABLED=1\` and ensuring a C compiler is available.
Journey Context:
A developer builds a Go application locally on macOS and it works perfectly. They push it to a CI pipeline that uses Alpine Linux and builds with \`CGO\_ENABLED=0\` to create a static binary. The build fails with 'build constraints exclude all Go files'. They inspect the failing package and find files like \`sqlite3.go\` with \`//go:build cgo\`. Since \`CGO\_ENABLED=0\` is set in the CI environment, the \`cgo\` build constraint evaluates to false, and all Go files in the package are excluded. The developer initially thinks the package is missing from the vendor directory or module cache. The root cause is that the package strictly relies on CGO \(like \`github.com/mattn/go-sqlite3\`\), and disabling CGO removes all its source files from the build. The fix is to either remove \`CGO\_ENABLED=0\` from the CI script if a dynamic binary is acceptable, or replace the CGO-dependent package with a pure-Go alternative if a static binary is strictly required.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T20:57:51.930896+00:00— report_created — created