From 7243a5a95fd44696b85b0634b8afb51b53ce07fe Mon Sep 17 00:00:00 2001 From: 1138-4EB <1138-4EB@users.noreply.github.com> Date: Thu, 9 Aug 2018 18:55:06 +0100 Subject: [PATCH] move config initialization to func --- cmd/filebrowser/main.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/cmd/filebrowser/main.go b/cmd/filebrowser/main.go index deee8e2e..e2bb787e 100644 --- a/cmd/filebrowser/main.go +++ b/cmd/filebrowser/main.go @@ -124,14 +124,7 @@ func printVersion() { os.Exit(0) } -func main() { - setupViper() - flag.Parse() - - if showVer { - printVersion() - } - +func initConfig() { // Add a configuration file if set. if config != "" { cfg := strings.TrimSuffix(config, filepath.Ext(config)) @@ -152,6 +145,17 @@ func main() { panic(err) } } +} + +func main() { + setupViper() + flag.Parse() + + if showVer { + printVersion() + } + + initConfig(); // Set up process log before anything bad happens. switch viper.GetString("Logger") {