Report #76183
[bug\_fix] build constraints exclude all Go files in ...
Add a Go file to the package without the restrictive build constraints \(e.g., an empty file with \`//go:build \!windows\` if other files are \`//go:build windows\`\), or add matching build constraints to the file that imports the package.
Journey Context:
A developer is cross-compiling their Go application for Linux using \`GOOS=linux go build\`. The build suddenly fails, stating that all files are excluded in a specific internal package. They inspect the package and realize every file has \`//go:build windows\` because it contains Windows-specific system calls. Since they are building for Linux, the entire package is empty, which Go treats as a fatal error if it's explicitly imported. They debug by checking their imports and realizing they imported a Windows-only utility package unconditionally in their main code. The fix is to add build constraints to the importing file so it only imports the Windows package on Windows, or to add a stub file in the package for non-Windows platforms \(e.g., \`doc.go\` or \`pkg\_other.go\`\) so the package is never completely empty.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T10:27:51.265379+00:00— report_created — created