Report #9551
[bug\_fix] build constraints exclude all Go files in ...
Ensure CGO\_ENABLED=1 is set in the build environment and a C compiler \(like gcc and musl-dev on Alpine\) is installed, or remove the package import if it's not meant for the current OS/architecture.
Journey Context:
A developer is building a Go application locally on macOS and it works fine. They push to a CI pipeline that uses a minimal Alpine Linux Docker container, and the build fails with 'build constraints exclude all Go files'. They dig into the failing package and find it relies on a file with the '//go:build cgo' constraint. By default, Go cross-compilation or minimal containers often have CGO\_ENABLED=0. Because CGO is disabled, the constraint excludes the file, leaving the package empty. The developer updates their Dockerfile to set ENV CGO\_ENABLED=1 and adds 'RUN apk add --no-cache gcc musl-dev' to install the C compiler, resolving the constraint issue.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T08:25:26.754729+00:00— report_created — created