mirror of https://github.com/spf13/viper.git
Fix panic while writing invalid ini
This commit is contained in:
parent
896fc959b3
commit
7da613aa94
4
viper.go
4
viper.go
|
@ -1616,6 +1616,10 @@ func (v *Viper) marshalWriter(f afero.File, configType string) error {
|
|||
for i := 0; i < len(keys); i++ {
|
||||
key := keys[i]
|
||||
lastSep := strings.LastIndex(key, ".")
|
||||
if lastSep < 0 {
|
||||
err := fmt.Errorf("missing key for %s", key)
|
||||
return ConfigMarshalError{err}
|
||||
}
|
||||
sectionName := key[:(lastSep)]
|
||||
keyName := key[(lastSep + 1):]
|
||||
if sectionName == "default" {
|
||||
|
|
Loading…
Reference in New Issue