Fix ToBool() to support int32, int64, uint, uint32, uint64, float32, float64
This commit is contained in:
parent
c01685bb84
commit
5d93088034
9
caste.go
9
caste.go
@ -79,8 +79,13 @@ func ToBoolE(i interface{}) (bool, error) {
|
|||||||
return b, nil
|
return b, nil
|
||||||
case nil:
|
case nil:
|
||||||
return false, nil
|
return false, nil
|
||||||
case int:
|
case int, int32, int64, uint, uint32, uint64:
|
||||||
if i.(int) != 0 {
|
if b != 0 {
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
return false, nil
|
||||||
|
case float32, float64:
|
||||||
|
if b != 0.0 {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
return false, nil
|
return false, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user