Report #3500
[bug\_fix] build constraints exclude all Go files in /path/to/package
Add a Go file to the package without the restrictive build constraints, or with the inverse constraint \(e.g., //go:build \!linux\), ensuring at least one file is included in every build environment.
Journey Context:
A developer writes a package that wraps OS-specific syscalls. They create sys\_linux.go with //go:build linux and sys\_windows.go with //go:build windows. They run go build on their Mac and get 'build constraints exclude all Go files'. They are confused because they only need the Linux build for production, but the Go toolchain requires every imported package to compile for the host environment during go build and go test. They try to bypass it with GOOS=linux go build, which works, but breaks their local IDE and testing. The correct fix is to create a stub file, sys\_other.go, with //go:build \!linux && \!windows \(or simply no build tags\) that provides no-op implementations of the package's exported functions, ensuring the package always contains at least one valid Go file regardless of the target OS.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T17:20:35.202055+00:00— report_created — created