backend, options: Prefer strings.Cut to SplitN

Also realigned the various "split into host:bucket:prefix"
implementations.
This commit is contained in:
greatroar authored and Michael Eischer committed 2022-12-02 19:19:14 +01:00
1 parent 60aa87bbab
commit 65612d797c
9 files changed
+56 -66

No files matched your search

+4 -8
View File
@@ -92,14 +92,10 @@ func (h helpList) Swap(i, j int) {
// splitKeyValue splits at the first equals (=) sign.
func splitKeyValue(s string) (key string, value string) {
data := strings.SplitN(s, "=", 2)
key = strings.ToLower(strings.TrimSpace(data[0]))
if len(data) == 1 {
// no equals sign is treated as the empty value
return key, ""
}
return key, strings.TrimSpace(data[1])
key, value, _ = strings.Cut(s, "=")
key = strings.ToLower(strings.TrimSpace(key))
value = strings.TrimSpace(value)
return key, value
}
// Parse takes a slice of key=value pairs and returns an Options type.