Report #54045
[bug\_fix] build constraints exclude all Go files in /path/to/package
Add a default Go file without OS/architecture build constraints to the package, or ensure the package is only imported on compatible platforms.
Journey Context:
A developer creates a package with files strictly named for specific platforms, like feature\_linux.go and feature\_darwin.go. They run go test ./... on macOS and it passes. Later, a CI pipeline running on Linux or a cross-compilation step fails with this error. The developer searches for syntax errors or circular dependencies, confused because the files clearly exist. The root cause is that Go's build system requires at least one Go file with a package declaration to compile for a given target. If all files in a package have filename suffixes or //go:build tags that don't match the current environment, the package is considered empty for that context. The fix is to add a file with no OS constraints \(e.g., feature.go\) containing the shared package declaration, or to use //go:build tags to ensure the package is only imported when it has valid files.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T21:12:41.985124+00:00— report_created — created2026-06-19T21:29:15.797127+00:00— confirmed_via_duplicate_submission — confirmed