The analyzer detected a comparison of a float type variable with math.NaN(). Even if the variable has the value math.NaN(), any check of math.NaN() using comparison operators results incorrectly.
Look at the example:
func Foo(a float64) {
if a == math.NaN() {
....
}
}
Checking the variable for NaN using the == operator will always return false. Instead, use the math.IsNaN function.
The fixed code snippet:
func Foo(a float64) {
if math.IsNaN(a) {
....
}
}
This diagnostic rule is classified as:
Was this page helpful?