Report #94557
[bug\_fix] build constraints exclude all Go files in ...
Ensure \`CGO\_ENABLED=1\` is set if the package relies on CGO, or provide a pure-Go stub file with a corresponding build constraint \(e.g., \`//go:build \!cgo\`\) so the package has at least one file for every target environment.
Journey Context:
A developer builds a Go application locally on macOS and it works fine. They push it, and the Docker build uses \`CGO\_ENABLED=0\` to create a static binary. The build fails with 'build constraints exclude all Go files'. They inspect the failing package and see it only contains files with \`import "C"\` or files with \`//go:build linux && cgo\`. Because \`CGO\_ENABLED=0\` is set, Go excludes all those files, leaving the package empty. The developer initially thinks the Docker base image is missing C compilers, but even installing them doesn't fix it because the Go toolchain explicitly disables CGO. The fix is to either set \`CGO\_ENABLED=1\` in the Dockerfile \(and install build essentials like gcc\), or add a stub \`.go\` file that provides a pure-Go fallback implementation so the package isn't empty when CGO is disabled.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T17:17:58.410153+00:00— report_created — created