Fix workaround for optional config file with Viper
There was a false error reported when the configuration file was found
This commit is contained in:
parent
534b3e5fcd
commit
b419cfde69
@ -126,14 +126,14 @@ func setupConfig() {
|
|||||||
viper.SetConfigType("toml")
|
viper.SetConfigType("toml")
|
||||||
viper.AddConfigPath(".")
|
viper.AddConfigPath(".")
|
||||||
|
|
||||||
err = viper.ReadInConfig()
|
|
||||||
|
|
||||||
viper.BindEnv("DEBUG")
|
viper.BindEnv("DEBUG")
|
||||||
viper.BindEnv("DISCORD_TOKEN")
|
viper.BindEnv("DISCORD_TOKEN")
|
||||||
viper.BindEnv("OPEN_WEATHER_MAP_TOKEN")
|
viper.BindEnv("OPEN_WEATHER_MAP_TOKEN")
|
||||||
|
|
||||||
if _, ok := err.(viper.ConfigFileNotFoundError); !ok {
|
if err := viper.ReadInConfig(); err != nil {
|
||||||
log.Fatalf("fatal error config file: %v", err)
|
if _, ok := err.(viper.ConfigFileNotFoundError); !ok {
|
||||||
|
log.Fatalf("fatal error config file: %v", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = viper.Unmarshal(&C)
|
err = viper.Unmarshal(&C)
|
||||||
|
Loading…
Reference in New Issue
Block a user