A package is imported only for its side effects without a comment that says why

tx0/go:undocumented-blank-importstrictwarningmaintainability

What it finds

import _ "github.com/lib/pq": a blank import runs a package only for the effects of its initialization, such as registering a driver or a codec. Nothing in the code shows which effect is wanted, so the import looks unused and is easily removed. A comment next to it says why it is there.

Reported are blank imports without a comment on the line before or at the end of the line, in packages other than main and in files other than tests, where such imports are expected. import _ "embed" is left alone.

From the rule's source, undocumented_blank_import.rs.

Turn it on, off or suppress it

The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/go:undocumented-blank-import" = "warning"

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:undocumented-blank-import] reason="..."

tx0 explain tx0/go:undocumented-blank-import shows the same in the terminal. Found a false positive? Report it.