From f34deb0eac95dec4f7060a502dad499bbe23aa44 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Sat, 23 Jan 2021 09:52:06 +0800 Subject: [PATCH] chore: Nested if can be replaced with else-if --- config/config.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/config/config.go b/config/config.go index 7210c7c..6a761d5 100644 --- a/config/config.go +++ b/config/config.go @@ -270,11 +270,9 @@ func LoadConf(confPath string) (ConfYaml, error) { // If a config file is found, read it in. if err := viper.ReadInConfig(); err == nil { fmt.Println("Using config file:", viper.ConfigFileUsed()) - } else { + } else if err := viper.ReadConfig(bytes.NewBuffer(defaultConf)); err != nil { // load default config - if err := viper.ReadConfig(bytes.NewBuffer(defaultConf)); err != nil { - return conf, err - } + return conf, err } }