2020-01-07 16:36:49 +00:00
|
|
|
package txt
|
2019-05-16 06:41:16 +00:00
|
|
|
|
|
|
|
import (
|
2019-06-13 18:26:01 +00:00
|
|
|
"strings"
|
2019-05-16 06:41:16 +00:00
|
|
|
)
|
|
|
|
|
2020-01-31 14:29:06 +00:00
|
|
|
// Bool casts a string to bool.
|
|
|
|
func Bool(s string) bool {
|
|
|
|
s = strings.TrimSpace(s)
|
|
|
|
|
2021-05-26 07:51:00 +00:00
|
|
|
if s == "" || No(s) {
|
2020-01-31 14:29:06 +00:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
return true
|
|
|
|
}
|
2021-05-26 07:51:00 +00:00
|
|
|
|
|
|
|
// Yes returns true if a string represents "yes".
|
|
|
|
func Yes(s string) bool {
|
|
|
|
s = strings.ToLower(strings.TrimSpace(s))
|
|
|
|
|
2021-05-26 09:04:14 +00:00
|
|
|
return strings.IndexAny(s, "ytjosiд") == 0
|
2021-05-26 07:51:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// No returns true if a string represents "no".
|
|
|
|
func No(s string) bool {
|
|
|
|
s = strings.ToLower(strings.TrimSpace(s))
|
|
|
|
|
2021-05-26 09:04:14 +00:00
|
|
|
return strings.IndexAny(s, "0nhfeн") == 0
|
2021-05-26 07:51:00 +00:00
|
|
|
}
|