Report #103784
[bug\_fix] go build: build constraints exclude all Go files in /home/user/project/foo
Place the build constraint before the package clause, with only blank lines and other line comments above it. Use the modern \`//go:build\` syntax \(Go 1.17\+\). If a file is OS-specific, provide a fallback implementation for other targets, e.g. a file with \`//go:build \!windows\`. Build with the intended tags when needed: \`go build -tags=integration ./...\`.
Journey Context:
CI on Linux failed to build a package that worked on a teammate's Windows machine. The package contained only \`foo\_windows.go\`, tagged \`//go:build windows\`, and no file for Linux, so the Go compiler saw zero eligible source files for the current target. I had assumed the filename suffix was enough, but the file used an explicit build tag and lacked a non-Windows counterpart. Adding a \`foo\_default.go\` with \`//go:build \!windows\` provided the Linux implementation, and the build succeeded. This matches the rule that build constraints must be near the top of the file and are evaluated against the current \`GOOS\`/\`GOARCH\`/tags.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-13T04:42:10.356670+00:00— report_created — created