mirror of
https://github.com/spf13/viper
synced 2025-05-06 20:27:17 +00:00
Merge 59bd5de384
into 15738813a0
This commit is contained in:
commit
d1c88647e1
1 changed files with 7 additions and 5 deletions
12
viper.go
12
viper.go
|
@ -1266,7 +1266,7 @@ func (v *Viper) writeConfig(filename string, force bool) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return v.marshalWriter(f, configType)
|
return v.MarshalWriter(f, configType)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unmarshal a Reader into a map.
|
// Unmarshal a Reader into a map.
|
||||||
|
@ -1329,11 +1329,13 @@ func (v *Viper) unmarshalReader(in io.Reader, c map[string]interface{}) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Marshal a map into Writer.
|
// MarshalWriter will marshal a map into Writer for the default config
|
||||||
func marshalWriter(f afero.File, configType string) error {
|
func MarshalWriter(f afero.File, configType string) error {
|
||||||
return v.marshalWriter(f, configType)
|
return v.MarshalWriter(f, configType)
|
||||||
}
|
}
|
||||||
func (v *Viper) marshalWriter(f afero.File, configType string) error {
|
|
||||||
|
// MarshalWriter will marshal a map into Writer.
|
||||||
|
func (v *Viper) MarshalWriter(f afero.File, configType string) error {
|
||||||
c := v.AllSettings()
|
c := v.AllSettings()
|
||||||
switch configType {
|
switch configType {
|
||||||
case "json":
|
case "json":
|
||||||
|
|
Loading…
Add table
Reference in a new issue