Report #1838
[bug\_fix] build constraint excludes all Go files in package
Check the build tags, file suffixes, and GOOS/GOARCH values used by the file and the build command. Use //go:build directives with proper boolean syntax. If a file has a platform-specific suffix like \_linux.go or \_amd64.go, ensure the target platform matches. Build with GOOS/GOARCH explicitly set in CI to catch cross-compilation regressions.
Journey Context:
A cross-platform CLI tool compiled fine on macOS but CI on Linux failed with 'build constraints exclude all Go files in package' for a subpackage. The package contained db\_darwin.go and db\_linux.go, but db\_linux.go had a stale build tag //go:build darwin left over from a copy-paste. On the maintainer's Mac, db\_darwin.go matched, so the bug was invisible. On Linux, neither file matched the constraints, leaving the package empty. The developer spent time reinstalling Go and deleting the module cache before noticing that go list -f '\{\{.GoFiles\}\}' -tags linux returned nothing. The fix was correcting the tag to //go:build linux and adding a CI matrix that runs GOOS=linux GOARCH=amd64 go build and GOOS=darwin GOARCH=arm64 go build on every PR. This caught a similar regression a week later in a windows-specific file.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T08:48:53.168356+00:00— report_created — created