Report #40301
[bug\_fix] build constraints exclude all Go files in ...
Enable CGO by setting CGO\_ENABLED=1 and ensure a C compiler \(like gcc or musl-gcc\) is installed in the build environment.
Journey Context:
A developer builds an application that uses a popular database driver like go-sqlite3. It compiles and runs perfectly on their macOS laptop. They push the code to a CI pipeline that uses a minimal Alpine Docker container, and the build fails with 'build constraints exclude all Go files'. They check the file system and the files exist. They look at the source code and see build tags like //go:build cgo. The realization hits: Go defaults to CGO\_ENABLED=0 when cross-compiling or when a C compiler isn't present. The Alpine container lacks gcc and musl-dev. The fix is to add the C compiler to the Dockerfile \(e.g., apk add build-base\) and explicitly set CGO\_ENABLED=1 so the Go toolchain compiles the CGO files.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T22:07:02.213265+00:00— report_created — created