Report #1312
[bug\_fix] build constraints exclude all Go files in
Ensure the package contains at least one file that matches the current build constraints \(GOOS/GOARCH, build tags\). If using CGO, set \`CGO\_ENABLED=1\`. If using custom build tags, pass them via \`-tags\`.
Journey Context:
A developer is building a cross-platform application. They pull a dependency that uses CGO, or they have a package with files tagged \`//go:build linux\`. They run \`GOOS=windows go build\` or \`CGO\_ENABLED=0 go build\` and encounter this error. They go down a rabbit hole checking if the package directory is empty or if they accidentally deleted files. They check the dependency's repository and see the \`.go\` files are there. The root cause is that every \`.go\` file in that package has a build constraint that doesn't match the current build environment \(e.g., all files have \`import "C"\` and \`CGO\_ENABLED=0\` is set, or all files have \`//go:build linux\` and the target is Windows\). The Go compiler cannot produce a package with zero source files. The fix is to adjust the build environment \(e.g., \`CGO\_ENABLED=1\` if CGO is needed and supported\) or avoid importing the package on platforms it doesn't support.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-14T15:41:48.802763+00:00— report_created — created