refactor function CheckTruth

This commit is contained in:
0x2d3c 2020-08-08 18:03:01 +08:00
parent 39c8d6220b
commit 3613aa4bf6

View File

@ -34,16 +34,14 @@ func IsChar(c rune) bool {
}
func CheckTruth(val interface{}) bool {
if v, ok := val.(bool); ok {
return v
}
if v, ok := val.(string); ok {
v = strings.ToLower(v)
return v != "false"
}
switch val.(type) {
case string:
return "false" != strings.ToLower(val.(string))
case bool:
return val.(bool)
default:
return !reflect.ValueOf(val).IsZero()
}
}
func ToStringKey(values ...interface{}) string {