You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The reason you're seeing an issue here is using two types in a case makes the type interface{}, not eitherfloat32 or float64 depending on the context.
From the spec:
Given an expression x of type interface{}, the following type switch:
switch i := x.(type) {
case nil:
printString("x is nil") // type of i is type of x (interface{})
case int:
printInt(i) // type of i is int
case float64:
printFloat64(i) // type of i is float64
case func(int) float64:
printFunction(i) // type of i is func(int) float64
case bool, string:
printString("type is bool or string") // type of i is type of x (interface{})
default:
printString("don't know the type") // type of i is type of x (interface{})
}
You're actually comparing interface{float64(0)} to int(0), which is obviously false since the types differ. Your 'fix' can actually just compare both separate cases to 0.
isEmptyValue isn't broken because Float64 returns a float64, not interface{T}.
What did you do?
I've ever faced a float comparing with 0 problem.When I did:
The result turns out to be false.
I fix it by
OK,Things above is not what I want to ask.The point is, I see this part in encoding/json 314 line
should it be modified as
?
What did you expect to see?
What did you see instead?
System details
The text was updated successfully, but these errors were encountered: