Report #84550
[bug\_fix] build constraints exclude all Go files in ...
Ensure at least one Go file in the package is included for the target OS/architecture, often by fixing CGO constraints \(e.g., adding a non-CGO stub file or setting CGO\_ENABLED=1\).
Journey Context:
A developer is building a Go application for a minimal Docker scratch container using 'CGO\_ENABLED=0 GOOS=linux go build'. The build fails with 'build constraints exclude all Go files'. They check the directory and see .go files present. Confused, they look at the file names and see 'syscall\_linux.go', which should be included. They then open the file and spot the build tag '//go:build linux && cgo'. Because CGO\_ENABLED=0 was set to ensure a static binary, the go tool excludes this file. Since there are no other files implementing the required package without CGO, the package is empty. The fix is either to enable CGO or, more commonly for static builds, to provide an alternative implementation file with a '//go:build linux && \!cgo' tag that provides the same API without relying on C.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T00:30:40.107283+00:00— report_created — created