mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-11 04:05:10 +02:00
Move ParseBool to optional (#33979)
(cherry picked from commit 25b6f388651c893ecafce918f27bef7e4ae9a967)
This commit is contained in:
parent
9018e5bc19
commit
f68d49cb9e
6 changed files with 31 additions and 33 deletions
|
@ -14,22 +14,11 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
|
||||
"forgejo.org/modules/optional"
|
||||
|
||||
"golang.org/x/crypto/ssh"
|
||||
"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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue