Go: Replace strings.Split() with strings.SplitSeq() #5337

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer
2025-11-25 14:26:29 +01:00
parent 590213572b
commit ebed7fa5b4
4 changed files with 7 additions and 11 deletions

View File

@@ -67,10 +67,8 @@ func (b ExtList) Set(extensions string) {
return return
} }
ext := strings.Split(extensions, ",") for ext := range strings.SplitSeq(extensions, ",") {
b.Add(ext)
for i := range ext {
b.Add(ext[i])
} }
} }

View File

@@ -22,8 +22,7 @@ func IsDomain(d string) bool {
if IsLocalSuffix(d) { if IsLocalSuffix(d) {
return false return false
} }
parts := strings.Split(d, ".") for p := range strings.SplitSeq(d, ".") {
for _, p := range parts {
if !IsLabel(p) { if !IsLabel(p) {
return false return false
} }

View File

@@ -60,10 +60,10 @@ func Authorization(c *gin.Context) (authType, authToken string) {
return "", "" return "", ""
} else if s := c.GetHeader(Auth); s == "" { } else if s := c.GetHeader(Auth); s == "" {
// Ignore. // Ignore.
} else if t := strings.Split(s, " "); len(t) != 2 { } else if typ, token, ok := strings.Cut(s, " "); !ok {
// Ignore. // Ignore.
} else { } else {
return ID(t[0]), ID(t[1]) return ID(typ), ID(token)
} }
return "", "" return "", ""

View File

@@ -14,10 +14,9 @@ func Title(s string) string {
return "" return ""
} }
blocks := strings.Split(s, "/") result := make([]string, 0, 4)
result := make([]string, 0, len(blocks))
for _, block := range blocks { for block := range strings.SplitSeq(s, "/") {
words := strings.Fields(block) words := strings.Fields(block)
if len(words) == 0 { if len(words) == 0 {