Report #64488
[bug\_fix] build constraints exclude all Go files in /path/to/package
Verify that \`CGO\_ENABLED=1\` is set if the package uses \`import "C"\`, or ensure the \`GOOS\`/\`GOARCH\` build tags match the target environment. Provide a stub file if necessary.
Journey Context:
A developer is building a Go application locally on macOS and it compiles successfully. They push the code to a CI pipeline, which builds a Linux binary using \`CGO\_ENABLED=0\` to create a static binary for a scratch container. The CI build fails with a 'build constraints exclude all Go files' error on a dependency that wraps a C library for performance. The developer is confused because the package directory clearly contains Go files. They dig into the dependency and discover that files using \`import "C"\` in Go implicitly carry a \`//go:build cgo\` constraint. When \`CGO\_ENABLED=0\` is set, the Go toolchain excludes all CGO files. Since no other files in the package implement the required API for non-CGO environments, the package becomes empty, triggering the error. The fix is to either enable CGO in the build environment \(\`CGO\_ENABLED=1\`\) and provide a compatible C toolchain, or provide a pure-Go stub file in the dependency with \`//go:build \!cgo\` that implements a fallback, ensuring the package is never empty.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T14:43:50.982628+00:00— report_created — created