Report #14221
[bug\_fix] build constraints exclude all Go files in ...
Ensure the package contains at least one file that matches the current OS/Architecture, or remove the overly restrictive build tags \(e.g., \`//go:build\` or \`// \+build\`\). If using CGO, ensure \`CGO\_ENABLED=1\` is set if the files require it.
Journey Context:
A developer is cross-compiling a Go application for Linux using \`GOOS=linux GOARCH=amd64 go build\`. The build fails, complaining that build constraints exclude all Go files in a specific package. They check the package and see it only contains files with \`//go:build darwin\` or \`//go:build windows\`. They also notice some files have \`//go:build cgo\`. They realize their CI pipeline sets \`CGO\_ENABLED=0\` by default for static binaries, which excludes all CGO files. Since the package only had CGO files for Linux, the entire package was excluded. They either add a non-CGO fallback file for Linux or update the CI pipeline to \`CGO\_ENABLED=1\`. The fix works because the Go build system strictly filters files based on build constraints before compilation; if a package ends up empty, it's a fatal error.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T20:55:25.621155+00:00— report_created — created