mirror of https://github.com/spf13/viper.git
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:
parent
11ae2b9392
commit
2715727d1f
3
viper.go
3
viper.go
|
@ -888,11 +888,10 @@ func (v *Viper) SaveConfig() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
f, err := os.Create(v.getConfigFile())
|
f, err := os.Create(v.getConfigFile())
|
||||||
defer f.Close()
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
defer f.Close()
|
||||||
|
|
||||||
switch v.getConfigType() {
|
switch v.getConfigType() {
|
||||||
case "json":
|
case "json":
|
||||||
|
|
Loading…
Reference in New Issue