github.com/sandwich-go/boost@v1.3.29/xstrings/boolean.go (about) 1 package xstrings 2 3 import "strings" 4 5 // Empty strings. 6 var emptyStringMap = map[string]struct{}{ 7 "": {}, 8 "0": {}, 9 "n": {}, 10 "no": {}, 11 "off": {}, 12 "false": {}, 13 } 14 15 // IsFalse 判断command解析获取的数据是否为false 16 func IsFalse(v string) bool { 17 _, ok := emptyStringMap[strings.ToLower(v)] 18 return ok 19 } 20 21 // IsTrue 判断command解析获取的数据是否为true 22 func IsTrue(v string) bool { return !IsFalse(v) }