mirror of
https://github.com/genuinetools/reg.git
synced 2024-09-17 16:11:01 -04:00
21 lines
389 B
Go
21 lines
389 B
Go
|
package opts
|
||
|
|
||
|
import (
|
||
|
"strings"
|
||
|
)
|
||
|
|
||
|
// ConvertKVStringsToMap converts ["key=value"] to {"key":"value"}
|
||
|
func ConvertKVStringsToMap(values []string) map[string]string {
|
||
|
result := make(map[string]string, len(values))
|
||
|
for _, value := range values {
|
||
|
kv := strings.SplitN(value, "=", 2)
|
||
|
if len(kv) == 1 {
|
||
|
result[kv[0]] = ""
|
||
|
} else {
|
||
|
result[kv[0]] = kv[1]
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return result
|
||
|
}
|