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
}
ext := strings.Split(extensions, ",")
for i := range ext {
b.Add(ext[i])
for ext := range strings.SplitSeq(extensions, ",") {
b.Add(ext)
}
}

View File

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

View File

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

View File

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