Report #48640
[bug\_fix] build constraints exclude all Go files in ...
Ensure at least one Go file in the package lacks build constraints, or add a file with build constraints matching the target OS/Architecture \(e.g., //go:build darwin\). If the package is only meant for other platforms, exclude it from the current build using a stub or by adjusting the import.
Journey Context:
A developer is working on a cross-platform CLI tool. They have a package \`system\` containing \`system\_linux.go\` and \`system\_windows.go\`, each with \`//go:build linux\` and \`//go:build windows\` respectively. They run \`go test ./...\` on their macOS development machine and encounter 'build constraints exclude all Go files'. They initially think a file is corrupted or missing a package declaration. They check the files, but everything looks fine. They then run \`go list -f '\{\{.GoFiles\}\}' ./system\` and see an empty list. The realization hits: the Go compiler evaluates build constraints per-package, and if ALL files in a package are excluded by constraints for the current GOOS/GOARCH, the package is considered empty and fails to compile. The fix is to add a \`system\_darwin.go\` file \(or a \`system\_other.go\` with \`//go:build \!linux && \!windows\`\) that provides a stub implementation for macOS, ensuring at least one file is included during the local build.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T12:07:14.187729+00:00— report_created — created