Report #88924
[bug\_fix] build constraints exclude all Go files in /path/to/package
Ensure the target OS/Architecture is supported by the package's build constraints, or add a default implementation file without OS/Arch constraints. If the package uses CGO, ensure \`CGO\_ENABLED=1\` is set.
Journey Context:
A developer is building their application for a Linux production environment using \`GOOS=linux GOARCH=amd64 go build\`. It fails with 'build constraints exclude all Go files'. They inspect the failing package's directory and see files named \`api\_darwin.go\` and \`api\_windows.go\`, but no \`api\_linux.go\`. The Go compiler evaluates \`//go:build\` constraints and file suffixes \(like \`\_darwin.go\`\) to filter files for the target OS. Since no files matched \`linux\`, the package was empty, causing the build to fail. They add an \`api\_linux.go\` file with the necessary Linux-specific implementations. Alternatively, if it was a CGO package \(like \`go-sqlite3\`\) and they had \`CGO\_ENABLED=0\`, the implicit \`cgo\` build constraint would exclude all CGO files. They fix the constraints or enable CGO, and the build succeeds because the compiler now finds valid Go files for the target.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T07:50:58.001960+00:00— report_created — created