Report #104484
[bug\_fix] build constraints exclude all Go files in /path/to/package
Update build constraint directives to use the correct syntax. For Go 1.17\+, ensure \`//go:build\` lines accompany old \`// \+build\` lines, or use only the new style. Remove or adjust constraints that unintentionally exclude all files for the target OS/arch.
Journey Context:
Developer upgraded from Go 1.16 to 1.18 and encountered a package that would not compile: 'build constraints exclude all Go files in ./internal/platform'. The package had only one Go file with an old-style \`// \+build linux\` constraint but no corresponding \`//go:build\` line. In Go 1.17 and later, both forms are needed unless the file is only built by earlier Go versions. The developer was building on a Linux host, so the constraint should match, but the error indicated that ALL files were excluded. Upon investigation, they found that the file also contained a \`//go:build ignore\` line inadvertently added by a tool. The root cause was a mistaken \`ignore\` tag that overrode the \`linux\` constraint. The fix: remove the \`//go:build ignore\` line and run \`gofmt -w\` to insert the correct \`//go:build linux\` line. The developer also confirmed that no other files existed in the package, so after the fix the file was included and built successfully.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-08-23T20:06:45.024881+00:00— report_created — created