Report #9757
[bug\_fix] build constraints exclude all Go files in ...
Ensure the target OS/Architecture matches the build constraints, or add a default implementation file with the inverse build constraint \(e.g., \`//go:build \!linux\`\) to the package.
Journey Context:
A developer is cross-compiling a CLI application or running tests. On their local macOS machine, \`go build\` works fine, but when they build for Linux \(\`GOOS=linux go build\`\) or run CI in a Docker container, they get 'build constraints exclude all Go files'. They dive into the package directory and find files like \`sys\_linux.go\` and \`sys\_windows.go\`, but no file for the target OS or a generic fallback. Alternatively, they might be building with \`CGO\_ENABLED=0\` and the only available files contain \`import "C"\`, which implicitly requires CGO. The Go compiler strictly filters files based on build tags and CGO settings; if no files remain for the package, it errors out. The fix is to either provide a stub file for the missing platform \(using \`//go:build \!linux && \!windows\`\) or adjust the build environment \(e.g., \`CGO\_ENABLED=1\`\) if the platform is supposed to be supported.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T08:55:22.669903+00:00— report_created — created