This commit is contained in:
Carlos Henrique Guardão Gandarez 2021-12-09 11:39:44 +01:00 committed by GitHub
commit b3194a4500
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1730,9 +1730,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.GetString(key))