1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-05 18:17:19 +00:00

Move ParseBool to optional (#33979)

This commit is contained in:
Lunny Xiao
2025-03-23 20:53:30 -07:00
committed by GitHub
parent 08510adefe
commit 25b6f38865
6 changed files with 31 additions and 34 deletions

View File

@ -11,21 +11,10 @@ import (
"strconv"
"strings"
"code.gitea.io/gitea/modules/optional"
"golang.org/x/text/cases"
"golang.org/x/text/language"
)
// OptionalBoolParse get the corresponding optional.Option[bool] of a string using strconv.ParseBool
func OptionalBoolParse(s string) optional.Option[bool] {
v, e := strconv.ParseBool(s)
if e != nil {
return optional.None[bool]()
}
return optional.Some(v)
}
// IsEmptyString checks if the provided string is empty
func IsEmptyString(s string) bool {
return len(strings.TrimSpace(s)) == 0