Report #90848
[bug\_fix] build constraints exclude all Go files in /path/to/package
Ensure the package contains at least one .go file that matches the current OS/Architecture, or check if CGO is disabled \(CGO\_ENABLED=0\) while the package relies on import "C".
Journey Context:
A developer builds their app locally on macOS and it works. They push to CI, which builds a Linux binary, often using a minimal Alpine container or setting CGO\_ENABLED=0 for a static binary. The build fails with 'build constraints exclude all Go files'. They check the code and the files exist in the repository. The rabbit hole: they look at file permissions or directory structure, or blame the CI runner. The real issue is build tags. If a file has //go:build linux && cgo but the CI sets CGO\_ENABLED=0, all files in that package are excluded from the build. Another common cause is a package with only \_windows.go files being compiled on a Linux CI runner. The fix is to either enable CGO in the build environment, add a default/stub implementation for the target OS, or fix the build tags to include a generic file.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T11:05:00.880111+00:00— report_created — created