Skip to content

Commit

Permalink
Fix file closing immediatly instead of in the defer
Browse files Browse the repository at this point in the history
  • Loading branch information
royvandewater committed Jun 5, 2018
1 parent 61f09cd commit 5febe60
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ func createConfig() (err error) {
fmt.Println(err.Error())
os.Exit(-1)
}
defer fatalOnError("Error closing config file", file.Close())
defer func() {
fatalOnError("Error closing config file", file.Close())
}()

// read flag values
host := viper.GetString("host")
Expand Down

0 comments on commit 5febe60

Please sign in to comment.