Report #63642
[bug\_fix] build constraints exclude all Go files
Ensure the package contains at least one Go file that applies to the target OS and architecture, or remove the import for the empty package. This usually means adding a generic file \(e.g., \`feature.go\`\) without build tags, or a file specific to your current OS \(e.g., \`feature\_darwin.go\`\).
Journey Context:
A developer is writing a cross-platform application and creates a package for low-level socket handling. They create \`socket\_linux.go\` and \`socket\_windows.go\`, adding \`//go:build linux\` and \`//go:build windows\` tags respectively. They attempt to run \`go test ./socket\` on their macOS development machine. The test fails with 'build constraints exclude all Go files'. The developer is baffled because the package works perfectly in their Linux Docker container. They dive into the Go build system documentation, suspecting a bug in the test runner. The root cause is that when building on macOS, both files are excluded by the build constraints, leaving the package completely empty, which is illegal in Go. The fix works because adding a \`socket\_darwin.go\` \(or a stub \`socket.go\` without constraints\) ensures that at least one file exists in the package for the target OS, allowing the Go compiler to resolve the package directory successfully.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T13:18:40.802081+00:00— report_created — created