mirror of
https://github.com/rancher/os.git
synced 2025-07-05 19:16:13 +00:00
use SplitN instead of manual split
This commit is contained in:
parent
d62eb3de5d
commit
38167f821b
@ -314,9 +314,8 @@ func Map2KVPairs(m map[string]string) []string {
|
|||||||
func KVPairs2Map(kvs []string) map[string]string {
|
func KVPairs2Map(kvs []string) map[string]string {
|
||||||
r := make(map[string]string, len(kvs))
|
r := make(map[string]string, len(kvs))
|
||||||
for _, kv := range kvs {
|
for _, kv := range kvs {
|
||||||
sepIdx := strings.Index(kv, "=")
|
s := strings.SplitN(kv, "=", 2)
|
||||||
k, v := kv[:sepIdx], kv[(sepIdx + 1):]
|
r[s[0]] = s[1]
|
||||||
r[k] = v
|
|
||||||
}
|
}
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user