Report #58969
[bug\_fix] build constraints exclude all Go files in /path/to/package
Enable CGO by setting \`CGO\_ENABLED=1\` and ensure a C compiler \(like \`gcc\` or \`musl-gcc\`\) is installed in the build environment, or use a pure-Go alternative if CGO cannot be enabled.
Journey Context:
A developer builds a Go application locally on macOS or Windows and it compiles successfully. They push the code to a CI/CD pipeline that uses a minimal Docker image \(like \`alpine\` or a \`scratch\`-based builder\). The build fails with this constraint error. They inspect the failing package and find \`import "C"\` and \`\#cgo\` directives. The CI environment either has \`CGO\_ENABLED=0\` by default \(common in some minimal Go images to ensure static linking\) or lacks a C compiler. The root cause is that the \`cgo\` build constraint requires CGO to be enabled and a C compiler to be present; when CGO is disabled, those files are excluded, leaving zero valid Go files for the package.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T05:28:09.976679+00:00— report_created — created