feat: better value formatting and handling

This commit is contained in:
yusing
2025-04-16 12:21:05 +08:00
parent 82f48d1248
commit 104e1b1d0a
2 changed files with 114 additions and 66 deletions

View File

@@ -2,6 +2,7 @@ package strutils
import (
"reflect"
"strconv"
)
type Parser interface {
@@ -24,3 +25,11 @@ func MustParse[T Parser](from string) T {
}
return t
}
func ParseBool(from string) bool {
b, err := strconv.ParseBool(from)
if err != nil {
return false
}
return b
}