Report #9352
[bug\_fix] build constraints exclude all Go files
Ensure at least one Go file in the package does not have build constraints that exclude the current GOOS/GOARCH, or add a stub file \(e.g., \`stub\_other.go\`\) with the inverse constraint \(e.g., \`//go:build \!linux\`\).
Journey Context:
A developer creates a new package with a single file \`api\_linux.go\` containing \`//go:build linux\`. They attempt to run \`go test\` on their macOS machine, but the compiler complains that the package has no files. They verify the file exists and is syntactically correct. The rabbit hole: they suspect a Go toolchain bug or a corrupted cache. The actual root cause is that Go requires every package to have at least one non-excluded \`.go\` file for the target architecture to be considered a valid package. Since \`api\_linux.go\` is excluded on macOS, the package is effectively empty. The fix is to add a file with the inverse constraint, like \`api\_other.go\` with \`//go:build \!linux\`, so the package compiles on all platforms.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T07:52:56.929224+00:00— report_created — created