mirror of
https://github.com/spf13/viper
synced 2025-05-11 06:37:27 +00:00
return nil if unable to parse instead of panicing
This commit is contained in:
parent
21e376d12e
commit
d6288da8b8
1 changed files with 3 additions and 0 deletions
3
viper.go
3
viper.go
|
@ -1191,6 +1191,9 @@ func parseStringToStringFlagValue(val string) map[string]string {
|
|||
result := make(map[string]string, len(elements))
|
||||
for _, element := range elements {
|
||||
pair := strings.SplitN(element, "=", 2)
|
||||
if len(pair) != 2 {
|
||||
return nil
|
||||
}
|
||||
result[pair[0]] = pair[1]
|
||||
}
|
||||
return result
|
||||
|
|
Loading…
Add table
Reference in a new issue