Report #62634
[bug\_fix] build constraints exclude all Go files in /path/to/package
Add a stub file with the inverse build constraint \(e.g., \`//go:build \!linux\`\) or ensure the correct \`GOOS\`/\`GOARCH\` and \`CGO\_ENABLED\` settings are used during compilation.
Journey Context:
A developer is building a Go application locally on macOS, and it compiles fine. When they push to CI, the build fails with 'build constraints exclude all Go files'. The CI environment is Linux, but the package in question uses CGO and only has files named \`sys\_unix.go\` with \`//go:build linux && cgo\`. The developer is confused because they are building on Linux in CI. They investigate and realize that the default Go build in their CI sets \`CGO\_ENABLED=0\` for static binaries. Because CGO is disabled, the \`cgo\` build constraint evaluates to false, excluding the only files in the package. The root cause is that build constraints are evaluated as a logical AND of the file's tags and the environment's tags; if a package relies on a specific combination \(like \`linux\` AND \`cgo\`\), and one is missing, the package becomes empty. The fix is either to enable CGO in the CI build \(\`CGO\_ENABLED=1\`\) or, if the package is meant to support non-CGO environments, to provide a fallback file with \`//go:build \!cgo\` containing no-op stubs so the package is never completely empty.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T11:36:59.620352+00:00— report_created — created