Report #16580
[bug\_fix] build constraints exclude all Go files in /path/to/package
Enable CGO by setting \`CGO\_ENABLED=1\` and ensure a C compiler \(like \`gcc\` or \`build-base\`\) is installed for the target architecture. If cross-compiling, use an appropriate cross-compiler.
Journey Context:
A developer is building a Go application that uses a package requiring CGO, such as \`github.com/mattn/go-sqlite3\`. They run \`go build\` in a minimal Docker container \(like Alpine\) or with \`CGO\_ENABLED=0\` set in their environment. The build fails, stating all Go files are excluded by build constraints. They inspect the failing package's source and see files with the \`// \+build cgo\` constraint or files ending in \`\_cgo.go\`. They realize that CGO is disabled by default in their environment or cross-compilation setup. By installing a C compiler \(e.g., \`apk add build-base\` in Alpine\) and explicitly setting \`CGO\_ENABLED=1\`, the build succeeds because the CGO-constrained files are now included.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T02:57:18.034510+00:00— report_created — created