initial commit
This commit is contained in:
commit
5ba52dd285
19 files changed
+639
No files matched your search
@@ -0,0 +1,24 @@
|
||||
package utils
|
||||
|
||||
import "strings"
|
||||
|
||||
func DecodeSettings(input string, pairDelim string, kvDelim string) map[string]string {
|
||||
result := make(map[string]string)
|
||||
pairs := strings.SplitSeq(input, pairDelim)
|
||||
|
||||
for pair := range pairs {
|
||||
if pair == "" {
|
||||
continue
|
||||
}
|
||||
kv := strings.SplitN(pair, kvDelim, 2)
|
||||
if len(kv) != 2 {
|
||||
continue
|
||||
}
|
||||
key := strings.TrimSpace(kv[0])
|
||||
value := strings.TrimSpace(kv[1])
|
||||
if key != "" {
|
||||
result[key] = value
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
Reference in new issue
Block a user