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 committed by Herkermer Sherwood
parent 3611c6c1c4
commit 4c3baa4a94

View file

@ -1082,11 +1082,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":