mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-06-24 22:39:06 +08:00
Conflicts: Gopkg.lock pkg/appsrv/appsrv.go pkg/cloudcommon/options.go pkg/compute/models/hosts.go pkg/compute/models/quotas.go pkg/compute/service/service.go pkg/mcclient/mcclient.go
26 lines
374 B
Go
26 lines
374 B
Go
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
|
|
}
|