mirror of
https://github.com/spf13/viper
synced 2025-05-06 20:27:17 +00:00
Fix toml return count error
This commit is contained in:
parent
c588a0c383
commit
4b195d0ed8
1 changed files with 6 additions and 5 deletions
11
viper.go
11
viper.go
|
@ -1365,20 +1365,21 @@ func (v *Viper) marshalWriter(f afero.File, configType string) error {
|
|||
}
|
||||
|
||||
case "toml":
|
||||
t := toml.TreeFromMap(c)
|
||||
s := t.String()
|
||||
_, err := f.WriteString(s)
|
||||
t, err := toml.TreeFromMap(c)
|
||||
if err != nil {
|
||||
return ConfigMarshalError{err}
|
||||
}
|
||||
s := t.String()
|
||||
if _, err := f.WriteString(s); err != nil {
|
||||
return ConfigMarshalError{err}
|
||||
}
|
||||
|
||||
case "yaml", "yml":
|
||||
b, err := yaml.Marshal(c)
|
||||
if err != nil {
|
||||
return ConfigMarshalError{err}
|
||||
}
|
||||
_, err = f.WriteString(string(b))
|
||||
if err != nil {
|
||||
if _, err = f.WriteString(string(b)); err != nil {
|
||||
return ConfigMarshalError{err}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue