Report #31068
[bug\_fix] build constraints exclude all Go files in ...
Ensure CGO\_ENABLED=1 is set and a C compiler is available in the environment, or remove the 'import C' statement if CGO is not strictly required.
Journey Context:
A developer builds a Go application locally on macOS or Linux and it compiles fine. They push the code to a Docker container based on Alpine or a CI pipeline that defaults to 'CGO\_ENABLED=0', and the build fails with 'build constraints exclude all Go files'. They check the package directory and see no explicit '//go:build' tags at the top of the files. Confused, they look closer and notice the file uses 'import "C"', which is the Cgo preamble. The rabbit hole involves checking OS-specific file suffixes \(like \_linux.go\) before realizing that 'import "C"' implicitly adds a 'cgo' build constraint. The fix works because enabling CGO satisfies the implicit build constraint added by the Cgo import, allowing the Go toolchain to include those files in the compilation process.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T06:32:14.048791+00:00— report_created — created