mirror of
https://github.com/spf13/viper
synced 2024-12-23 03:57:01 +00:00
fix panic while saving ini file
This commit is contained in:
parent
13df721090
commit
074ed18f7e
1 changed files with 5 additions and 2 deletions
7
viper.go
7
viper.go
|
@ -1644,9 +1644,12 @@ func (v *Viper) marshalWriter(f afero.File, configType string) error {
|
|||
for i := 0; i < len(keys); i++ {
|
||||
key := keys[i]
|
||||
lastSep := strings.LastIndex(key, ".")
|
||||
sectionName := key[:(lastSep)]
|
||||
sectionName := ""
|
||||
if lastSep > 0 {
|
||||
sectionName = key[:(lastSep)]
|
||||
}
|
||||
keyName := key[(lastSep + 1):]
|
||||
if sectionName == "default" {
|
||||
if sectionName == ini.DefaultSection {
|
||||
sectionName = ""
|
||||
}
|
||||
cfg.Section(sectionName).Key(keyName).SetValue(v.Get(key).(string))
|
||||
|
|
Loading…
Reference in a new issue