Report #52008
[bug\_fix] build constraints exclude all Go files in /path/to/package
Set \`CGO\_ENABLED=1\` in the build environment and ensure a C compiler \(like gcc\) is installed, or remove the dependency that requires CGO if cross-compiling to an environment where it is unavailable.
Journey Context:
A developer successfully builds a Go application locally on macOS or Windows and deploys it to a minimal Docker container \(like Alpine or Scratch\). The build fails in CI with this error. They inspect the failing package and find \`import "C"\` at the top of the files, meaning it relies on CGO. By default, Go sets \`CGO\_ENABLED=0\` when cross-compiling or when no C compiler is found. The developer was unknowingly relying on CGO locally because they had a C compiler present. The fix is to explicitly enable CGO in the Dockerfile \(\`ENV CGO\_ENABLED=1\`\) and install \`build-base\` \(Alpine\) or \`gcc\` \(Debian\) so the C toolchain is available during the build.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T17:47:18.889986+00:00— report_created — created