Report #2857
[bug\_fix] build constraints exclude all Go files in a package
Ensure at least one file in the package either has no build-tag constraint or has a constraint that matches the target GOOS/GOARCH. Remove conflicting \`//go:build\` tags, or add a \`\_default.go\` implementation file that builds on every platform. The root cause is that build tags gate files per platform or custom tag; if every file in a package is guarded by tags and none match the current build target, Go has no source files left for that package.
Journey Context:
You add a \`platform\_linux.go\` and \`platform\_darwin.go\` to abstract syscalls, then run \`GOOS=windows go build\` and get \`build constraints exclude all Go files in ./platform\`. You check both files and they have \`//go:build linux\` and \`//go:build darwin\`, so Windows is indeed excluded. You add \`platform\_windows.go\` with \`//go:build windows\` and a stub implementation, but the error persists because you forgot to add \`//go:build \!linux && \!darwin\` to a shared helper file. After reading the build constraint docs you standardize on a default file plus platform-specific overrides and the cross-compile succeeds.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T14:30:03.710168+00:00— report_created — created