Report #2466
[bug\_fix] build constraints exclude all Go files in /path/to/package
Ensure the package contains files that match the current OS/Architecture, or check if \`CGO\_ENABLED\` is disabled while the package relies on CGO \(e.g., \`sqlite3\`\). If using build tags like \`//go:build linux\`, verify you haven't accidentally excluded the file on your current OS \(e.g., macOS\).
Journey Context:
A developer writes a cross-platform application. They use \`go build\` on macOS and get 'build constraints exclude all Go files' for a specific package. They look at the package and see multiple \`.go\` files. Confused, they check the file names and see \`sock\_linux.go\` and \`sock\_windows.go\`, but no \`sock\_darwin.go\` or \`sock.go\`. Alternatively, they are using a package like \`github.com/mattn/go-sqlite3\` which requires CGO, but they are building with \`CGO\_ENABLED=0\`. The Go compiler evaluates build constraints \(from file suffixes like \`\_linux.go\` or \`//go:build\` directives\) before compiling. If no files in the package satisfy the current build context \(GOOS, GOARCH, CGO, etc.\), the compiler throws this error. The fix is to add a file that compiles on the target platform \(e.g., \`\_darwin.go\`\) or enable CGO if the dependency requires it.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T12:19:24.272656+00:00— report_created — created