chore: Nested if can be replaced with else-if

This commit is contained in:
Bo-Yi Wu 2021-01-23 09:52:06 +08:00
parent 56d0eb0e6a
commit f34deb0eac
1 changed files with 2 additions and 4 deletions

View File

@ -270,13 +270,11 @@ 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
}
}
}
// Core
conf.Core.Address = viper.GetString("core.address")