| 1 | package formatscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/format`/ |
| 2 | |
| 3 | import ( |
| 4 | "strconvscip-go gomod github.com/golang/go/src . strconv/" |
| 5 | "stringsscip-go gomod github.com/golang/go/src . strings/" |
| 6 | ) |
| 7 | |
| 8 | // ParseBool returns true for "1","true","yes" or false for "0","false","no" or defaultValue for any other value. |
| 9 | func ParseBoolscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/format`/ParseBool().(value string, defaultValue bool) (bool, bool) { |
| 10 | switch stringsscip-go gomod github.com/golang/go/src . strings/.ToLowerscip-go gomod github.com/golang/go/src . strings/ToLower().(value) { |
| 11 | case "true", "1", "yes", "y": |
| 12 | return true, true |
| 13 | case "false", "0", "no", "n": |
| 14 | return false, true |
| 15 | default: |
| 16 | return defaultValue, false |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | // PrintBool returns "Yes" if value is true, otherwise returns "No". |
| 21 | func PrintBoolscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/format`/PrintBool().(value bool) string { |
| 22 | if value { |
| 23 | return "Yes" |
| 24 | } |
| 25 | |
| 26 | return "No" |
| 27 | } |
| 28 | |
| 29 | // IsNumber returns whether the specified string is number-like. |
| 30 | func IsNumberscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/format`/IsNumber().(value string) bool { |
| 31 | _, err := strconvscip-go gomod github.com/golang/go/src . strconv/.ParseFloatscip-go gomod github.com/golang/go/src . strconv/ParseFloat().(value, 64) |
| 32 | |
| 33 | return err == nil |
| 34 | } |