Report #60693
[bug\_fix] build constraints exclude all Go files in /path/to/package
Add a generic Go file without build constraints to the package, or add a file with build constraints matching the target OS/Architecture \(e.g., \`//go:build \!linux\` or \`//go:build darwin\`\).
Journey Context:
A developer is building a cross-platform application and creates a new package \`netutils\`. They add \`netutils\_linux.go\` with \`//go:build linux\` and \`netutils\_windows.go\` with \`//go:build windows\`. When they run \`go build\` on their Mac, they get the 'build constraints exclude all Go files' error. They check for syntax errors, verify the package declarations, and try running \`go clean -cache\`, but nothing works. They wonder if macOS isn't supported by Go modules. The realization hits when they look at the package from the compiler's perspective: for the \`darwin\` target, \*both\* files in the \`netutils\` package are excluded by the build constraints. Go requires that every imported package resolves to at least one valid Go file for the target environment. The fix is to add a \`netutils\_darwin.go\` with \`//go:build darwin\`, or a \`netutils\_default.go\` with \`//go:build \!linux && \!windows\`, ensuring the package is never completely empty regardless of the compilation target.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T08:21:39.423292+00:00— report_created — created