Report #63870
[bug\_fix] build constraints exclude all Go files in
Ensure that every package has at least one file that builds on all target platforms \(like a common stub file\), or remove erroneous build constraints that are excluding all files for the current GOOS/GOARCH.
Journey Context:
A developer is writing a cross-platform package and creates a file named \`sys\_darwin.go\` with the build tag \`//go:build darwin\`. They also have a \`sys\_linux.go\` for Linux. They run \`go test\` on their Mac, and it fails with this error on a package that imports their \`sys\` package. They check the files, and the tags look correct. They dig deeper and realize they accidentally put \`//go:build linux\` on the only file in a sub-package that is imported unconditionally by their main code. When building on a Mac, the Go compiler evaluates the build constraints, excludes the Linux file, and finds zero files left in the directory for the current OS/Architecture. Since an imported package cannot be empty, the build fails. The fix is to ensure that every package has at least one file that builds on all platforms \(like a \`sys.go\` with common code or an empty stub\), or to remove the build constraint from the file if it was applied erroneously. This works because Go requires a valid package declaration for every imported path, regardless of the target OS.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T13:41:35.645668+00:00— report_created — created