From 5febe60b74dba0167e78746a5d9347d922f5ce25 Mon Sep 17 00:00:00 2001 From: Roy van de Water Date: Tue, 5 Jun 2018 10:26:26 -0700 Subject: [PATCH] Fix file closing immediatly instead of in the defer --- cmd/root.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/root.go b/cmd/root.go index b13c543b4..e84207177 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -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")