Report #85207
[bug\_fix] build constraints exclude all Go files
Ensure the package has at least one file that applies to the current GOOS/GOARCH, or use GOOS= go build to cross-compile/test for the target environment.
Journey Context:
A developer is building a cross-platform application and creates a file named network\_linux.go containing Linux-specific socket logic. They run go build ./... on their macOS machine, and the build fails with build constraints exclude all Go files. The developer is puzzled because the code compiles fine on their Linux CI server. The rabbit hole involves checking for syntax errors or missing package declarations, but the real issue is that the package only contains files with \_linux.go build tags. When building on macOS, Go excludes all files in that package because none match the macOS build constraints, resulting in an empty package, which is illegal. The fix is to either add a stub file for other OSes \(e.g., network\_other.go\) or, if the package is only meant for Linux, to build/test it using GOOS=linux go build ./... to explicitly target the Linux environment.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T01:36:16.670761+00:00— report_created — created