Report #2601
[bug\_fix] build constraints exclude all Go files in ...
Ensure the package contains at least one file with build constraints that match the target OS/Architecture, or add a file without build constraints. If using CGO, ensure \`CGO\_ENABLED=1\` is set.
Journey Context:
A developer is building a Go application for Linux \(\`GOOS=linux\`\) but developing on macOS. They run \`GOOS=linux go build .\` and get an error that build constraints exclude all Go files in a specific package. They look at the package and see it only contains files like \`foo\_linux.go\`. They wonder why it's excluded since they are building for Linux. Then they notice the file also has \`//go:build cgo && linux\`. They are building with \`CGO\_ENABLED=0\` \(the default in many minimal CI environments or cross-compilation setups\). The root cause is that the combined build tag expression evaluates to false for the current build environment. The fix is either to enable CGO if the package requires it \(\`CGO\_ENABLED=1\`\), or provide a stub file for non-CGO builds \(e.g., \`foo\_stub.go\` with \`//go:build \!cgo\`\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T13:20:12.218544+00:00— report_created — created