mirror of
https://github.com/spf13/viper
synced 2025-05-06 20:27:17 +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
3611c6c1c4
commit
4c3baa4a94
1 changed files with 1 additions and 2 deletions
3
viper.go
3
viper.go
|
@ -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":
|
||||
|
|
Loading…
Add table
Reference in a new issue