A build constraint comes after the package clause, where the go tool ignores it
What it finds
A //go:build line after the package clause: the go tool reads build constraints only from the comments before the package clause, so the file is built for every platform and tag, which usually ends in duplicate declarations on some platforms or code that does not compile on others. The same holds for the older // +build form.
Reported are line comments that start with //go:build or // +build anywhere after the package clause.
From the rule's source, misplaced_build_constraint.rs.
//go:build linux package p //go:build windowstx0 reports: this build constraint follows the package clause // +build darwintx0 reports: this build constraint follows the package clause // The comment //go:build in prose is fine.func f() {} Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/go:misplaced-build-constraint" = "off"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/go:misplaced-build-constraint] reason="..."tx0 explain tx0/go:misplaced-build-constraint shows the same in the terminal. Found a false positive? Report it.