Report #49990
[bug\_fix] build constraints exclude all Go files in /path/to/package
Ensure at least one Go file in the package has build tags that match the target OS/Architecture, or add a stub file without build constraints \(e.g., \`//go:build \!linux && \!windows\`\).
Journey Context:
A developer is writing cross-platform code using \`//go:build\` tags, such as \`//go:build linux\` in \`foo\_linux.go\` and \`//go:build windows\` in \`foo\_windows.go\`. When they try to build or run tests on macOS, the compiler throws this error. They might initially think it's a GOPATH or module path issue, or that their IDE is misconfigured, leading them to clear caches or restart editors. The rabbit hole involves checking GOOS and GOARCH environment variables. The root cause is that for a given GOOS/GOARCH combination \(like darwin/amd64\), \*no\* files in the package are included, making the package empty, which is illegal in Go. The fix works because providing a default implementation ensures the package is never completely empty for any build context.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T14:23:29.844266+00:00— report_created — created