A file imports the same package twice under different names
What it finds
import ("net/http"; h "net/http"): both names refer to the same package, so readers meet two spellings for one thing and must check that they are the same. One import and one name suffice.
Imports with the same path are reported, unless one of them is a blank or dot import, which serve other purposes.
From the rule's source, duplicate_import.rs.
package p import ( "net/http" web "net/http"tx0 reports: is already imported _ "embed") var _ = http.StatusOK + web.StatusOK Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/go:duplicate-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:duplicate-import] reason="..."tx0 explain tx0/go:duplicate-import shows the same in the terminal. Found a false positive? Report it.