Fixed the issue of incorrect defer and error checking order. The error checking must be first otherwise it will cause panic.

This commit is contained in:
g3rk6 2016-01-25 22:56:20 -05:00
parent 11ae2b9392
commit 2715727d1f

View file

@ -888,11 +888,10 @@ func (v *Viper) SaveConfig() error {
}
f, err := os.Create(v.getConfigFile())
defer f.Close()
if err != nil {
return err
}
defer f.Close()
switch v.getConfigType() {
case "json":