Report #57149
[bug\_fix] build constraints exclude all Go files in
Ensure the package contains at least one file that matches the current build environment. If building with CGO\_ENABLED=0, use a CGO-free alternative library or enable CGO. If cross-compiling, verify GOOS/GOARCH suffixes.
Journey Context:
A developer is building a minimal Docker image using 'FROM scratch' and sets CGO\_ENABLED=0 to create a statically linked binary. The build suddenly fails with this error on a dependency like github.com/mattn/go-sqlite3. They check the repository and see Go files exist, so they are confused. The root cause is Go's build constraint system. The failing package only contains Go files with the 'cgo' build tag \(e.g., '// \+build cgo'\). Because CGO is disabled, the compiler filters out every single file in that directory, leaving nothing to compile. The fix is either to enable CGO \(and use a different base image like alpine\) or replace the dependency with a package that provides pure Go implementations \(e.g., modernc.org/sqlite\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T02:24:47.655806+00:00— report_created — created