Skip to content

Commit

Permalink
improved toBool for next release
Browse files Browse the repository at this point in the history
  • Loading branch information
hedzr committed Feb 20, 2024
1 parent bf4d6e0 commit ee7e5e4
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion cvts.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,18 @@ func anyToBool(data any) bool {

func toBool(s string) bool {
_, ok := stringToBoolMap[strings.ToLower(s)]
return ok
if ok {
return ok
}
u, err := strconv.ParseUint(s, 10, 64)
if err != nil {
i, err1 := strconv.ParseInt(s, 10, 64)
if err1 != nil {
return false
}
return i != 0
}
return u > 0
}

var stringToBoolMap = map[string]struct{}{
Expand Down

0 comments on commit ee7e5e4

Please sign in to comment.