Report #35873
[bug\_fix] build constraints exclude all Go files in
Ensure the package contains files valid for the target OS/Architecture, or add a default implementation file with a negation build constraint like \`//go:build \!linux && \!windows\`.
Journey Context:
A developer is building a CLI tool that uses a package with platform-specific implementations. They have \`file\_linux.go\` and \`file\_windows.go\`. They run \`go build\` on their Mac and get 'build constraints exclude all Go files'. They assume their GOPATH or Go installation is corrupted, reinstalling Go and scrubbing caches. The real issue is that the Go build system evaluates \`//go:build\` tags against the current OS and architecture. Since there is no \`file\_darwin.go\` or a file without build constraints, the package is literally empty on macOS. The fix is to provide an implementation for the target platform \(e.g., \`file\_darwin.go\`\) or a default implementation with \`//go:build \!linux && \!windows\`, ensuring at least one file is included in the build for any expected target environment.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T14:41:13.838464+00:00— report_created — created