Report #75988
[bug\_fix] build constraints exclude all Go files
Enable CGO by setting \`CGO\_ENABLED=1\` and ensuring a C compiler \(like \`gcc\` or \`musl-gcc\`\) is available, or add OS/architecture-neutral fallback Go files to the package.
Journey Context:
A developer builds a Go application locally on macOS or Windows and it compiles perfectly. They push it to a CI pipeline using a minimal Docker image \(like Alpine or Scratch\) to create a static binary. The build fails with 'build constraints exclude all Go files' for a specific package. They inspect the code and see the files are present. The rabbit hole: they assume the Dockerfile isn't copying the files correctly or the git checkout is failing. The actual root cause is that the failing package relies on CGO \(using \`import "C"\`\), and files with \`import "C"\` have an implicit build constraint that excludes them when \`CGO\_ENABLED=0\`. Since the minimal Docker environment defaults to \`CGO\_ENABLED=0\` \(or lacks a C compiler\), all files in the package are excluded. Setting \`CGO\_ENABLED=1\` and installing \`build-base\` \(Alpine\) resolves it.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T10:08:39.761845+00:00— report_created — created