Report #83469
[bug\_fix] build constraints exclude all Go files
Ensure the package contains at least one .go file without build constraints \(or constraints matching the target OS/Architecture\), or explicitly set the target OS/Architecture using GOOS and GOARCH if cross-compiling.
Journey Context:
A developer is writing a cross-platform application and creates a file named network\_linux.go with the //go:build linux constraint. They also have network\_darwin.go and network\_windows.go. They try to build or run tests on their Mac, but the compiler complains that all files are excluded. The developer goes down a rabbit hole of checking CGO\_ENABLED, file permissions, and GOPATH, thinking the Go toolchain is ignoring their files. The actual root cause is that for the current GOOS/GOARCH combination \(e.g., darwin/amd64\), every single .go file in the package has a //go:build tag that evaluates to false. For instance, they might have forgotten to add the //go:build darwin tag to network\_darwin.go, or they are running go test ./... which attempts to build all packages for the host OS, including a package meant only for Linux. The fix is to add a stub file for the current OS or fix the build tags.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T22:41:27.111808+00:00— report_created — created