Report #101481
[bug\_fix] build constraints exclude all Go files in ...
Use the modern \`//go:build\` syntax \(Go 1.17\+\) and ensure there is a blank line between the build constraint and the \`package\` clause. Verify that file name suffixes \(\`\_linux.go\`, \`\_windows.go\`, \`\_amd64.go\`\) or explicit tags match the target \`GOOS\`/\`GOARCH\`.
Journey Context:
A developer adds a \`//go:build linux\` line to the top of a platform-specific file but forgets the required blank line before \`package main\`. Go treats the directive as an ordinary comment and applies no constraint, so on Windows the file compiles and references \`unix.Syscall\`, producing undefined-symbol errors instead of the expected exclusion. They then try \`// \+build linux\` and it works, but linters complain about the deprecated form. The real issue is the missing newline: the build constraint must be separated from the package clause. After switching to \`//go:build linux\` with a blank line and aligning file suffixes with the intended targets, cross-compilation with \`GOOS=windows go build\` succeeds.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-07T04:55:47.571180+00:00— report_created — created