-0.0 is written for negative zero, but the constant is positive zero
What it finds
x := -0.0: Go's constants are exact numbers, and exact zero has no sign, so -0.0 is the same constant as 0.0 and the variable holds positive zero. Negative zero is made at run time, as math.Copysign(0, -1).
Reported is - applied to a floating-point literal whose digits are all zero.
From the rule's source, negative_zero_literal.rs.
package p func f() (float64, float64, float64) { a := -0.0tx0 reports: a constant zero has no sign b := -0.5 c := -0e3tx0 reports: a constant zero has no sign return a, b, c - 0} 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:negative-zero-literal" = "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:negative-zero-literal] reason="..."tx0 explain tx0/go:negative-zero-literal shows the same in the terminal. Found a false positive? Report it.