refactor: use slices.Contains to simplify code

Signed-off-by: tongjicoder <tongjicoder@icloud.com>
This commit is contained in:
tongjicoder 2025-05-27 14:43:50 +08:00 committed by Nicolas De loof
parent d49a68ecbf
commit 2e71440bee
14 changed files with 32 additions and 47 deletions

View file

@ -21,16 +21,6 @@ import (
"strings"
)
// StringContains check if an array contains a specific value
func StringContains(array []string, needle string) bool {
for _, val := range array {
if val == needle {
return true
}
}
return false
}
// StringToBool converts a string to a boolean ignoring errors
func StringToBool(s string) bool {
s = strings.ToLower(strings.TrimSpace(s))