A variable is declared with a type and the zero value it would have anyway
What it finds
var count int = 0: a variable declared with a type starts as the zero value of that type, so var count int says the same.
Reported is a var declaration of one name with a predeclared type and the zero value of that type: 0 for the numeric types, "" for string, false for bool. The fix removes the value and is safe.
From the rule's source, explicit_zero_value.rs.
package p var count int = 0tx0 reports: int variables start as 0 already var name string = "x" var ready bool = falsetx0 reports: bool variables start as false already 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:
[rules]
"tx0/go:explicit-zero-value" = "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:explicit-zero-value] reason="..."tx0 explain tx0/go:explicit-zero-value shows the same in the terminal. Found a false positive? Report it.