mirror of
https://github.com/spf13/viper
synced 2024-12-22 19:47:01 +00:00
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
1 changed files with 1 additions and 2 deletions
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 a new issue