25
vendor/github.com/anacrolix/missinggo/strbool.go
generated
vendored
Normal file
25
vendor/github.com/anacrolix/missinggo/strbool.go
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
package missinggo
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"unicode"
|
||||
)
|
||||
|
||||
func StringTruth(s string) (ret bool) {
|
||||
s = strings.TrimFunc(s, func(r rune) bool {
|
||||
return r == 0 || unicode.IsSpace(r)
|
||||
})
|
||||
if s == "" {
|
||||
return false
|
||||
}
|
||||
ret, err := strconv.ParseBool(s)
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
i, err := strconv.ParseInt(s, 0, 0)
|
||||
if err == nil {
|
||||
return i != 0
|
||||
}
|
||||
return true
|
||||
}
|
||||
Reference in New Issue
Block a user