Report #42847
[bug\_fix] build constraints exclude all Go files in /path/to/package
Ensure the package contains at least one Go file that matches the current build constraints \(OS, architecture, or custom build tags\). Check for '//go:build' directives that might be too restrictive.
Journey Context:
A developer writes a package with files intended only for Linux, using '//go:build linux' at the top of all files. They try to build or test the application on their macOS machine, and the compiler throws 'build constraints exclude all Go files'. They think the import path is wrong or the files are missing. They check the filesystem, see the files, and get confused. They dig into CGO dependencies, thinking it's a CGO issue. The root cause is simply that every single .go file in the package has a '//go:build linux' tag, leaving zero files for darwin/amd64. The fix is to either add a stub file for other OSes \(e.g., '//go:build \!linux'\), or run the build with 'GOOS=linux go build'.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T02:23:10.959641+00:00— report_created — created