mirror of
https://github.com/spf13/viper
synced 2025-05-15 08:37:19 +00:00
Merge 074ed18f7e
into c43197d858
This commit is contained in:
commit
b3194a4500
1 changed files with 5 additions and 2 deletions
7
viper.go
7
viper.go
|
@ -1730,9 +1730,12 @@ func (v *Viper) marshalWriter(f afero.File, configType string) error {
|
||||||
for i := 0; i < len(keys); i++ {
|
for i := 0; i < len(keys); i++ {
|
||||||
key := keys[i]
|
key := keys[i]
|
||||||
lastSep := strings.LastIndex(key, ".")
|
lastSep := strings.LastIndex(key, ".")
|
||||||
sectionName := key[:(lastSep)]
|
sectionName := ""
|
||||||
|
if lastSep > 0 {
|
||||||
|
sectionName = key[:(lastSep)]
|
||||||
|
}
|
||||||
keyName := key[(lastSep + 1):]
|
keyName := key[(lastSep + 1):]
|
||||||
if sectionName == "default" {
|
if sectionName == ini.DefaultSection {
|
||||||
sectionName = ""
|
sectionName = ""
|
||||||
}
|
}
|
||||||
cfg.Section(sectionName).Key(keyName).SetValue(v.GetString(key))
|
cfg.Section(sectionName).Key(keyName).SetValue(v.GetString(key))
|
||||||
|
|
Loading…
Add table
Reference in a new issue