Report #102950
[bug\_fix] build constraint excludes file unexpectedly \(e.g., \`//go:build linux\` file ignored on macOS\)
Use filename suffixes \(\`\_linux.go\`, \`\_windows.go\`, \`\_test.go\`\) instead of or in addition to build tags where possible, because Go applies suffix constraints automatically. If build tags are required, put them as the first non-comment, non-blank line and use the modern \`//go:build\` form followed by a blank line and a legacy \`// \+build\` line if supporting Go <1.17.
Journey Context:
A cross-platform CLI had a file \`sysinfo.go\` starting with \`//go:build linux\`. On macOS, \`go build ./...\` omitted the file silently and produced undefined-symbol errors for \`getSysInfo\`, even though the function name was correct. The developer thought the package was broken and reinstalled the Go toolchain. After reading the build output carefully, they realized the file was excluded by the build tag. They split the implementation into \`sysinfo\_linux.go\` and \`sysinfo\_other.go\` using filename suffixes, removing the need for build tags entirely and making the intent obvious at a glance.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-10T04:45:43.680759+00:00— report_created — created