diff --git a/viper.go b/viper.go index f61f4ed..ad8b658 100644 --- a/viper.go +++ b/viper.go @@ -1649,7 +1649,7 @@ func (v *Viper) marshalWriter(f afero.File, configType string) error { if sectionName == "default" { sectionName = "" } - cfg.Section(sectionName).Key(keyName).SetValue(v.Get(key).(string)) + cfg.Section(sectionName).Key(keyName).SetValue(cast.ToString(v.Get(key))) } cfg.WriteTo(f) }