Added method to write into YAML file.

This commit is contained in:
g3rk6 2016-01-10 21:59:10 -05:00
parent d5c009456e
commit 11ae2b9392

View file

@ -40,6 +40,7 @@ import (
jww "github.com/spf13/jwalterweatherman"
"github.com/spf13/pflag"
"gopkg.in/fsnotify.v1"
"gopkg.in/yaml.v2"
)
var v *Viper
@ -909,6 +910,14 @@ func (v *Viper) SaveConfig() error {
jww.FATAL.Println("Panic while encoding into TOML format.")
}
w.Flush()
case "yaml", "yml":
b, err := yaml.Marshal(v.AllSettings())
if err != nil {
jww.FATAL.Println("Panic while encoding into YAML format.")
}
f.WriteString(string(b))
}
return nil