feat: add env configuration support (#57)

This commit is contained in:
Devin Buhl 2023-04-11 01:51:29 -04:00 committed by GitHub
parent 4afbe82283
commit fa28701928
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -63,14 +63,9 @@ func Load(configPath string) Config {
configFile = configPath configFile = configPath
viper.SetConfigFile(configPath) viper.SetConfigFile(configPath)
viper.SetEnvPrefix("speedtest")
if err := viper.ReadInConfig(); err != nil { viper.AutomaticEnv()
if _, ok := err.(viper.ConfigFileNotFoundError); ok { viper.ReadInConfig()
log.Warnf("No config file found in search paths, using default values")
} else {
log.Fatalf("Error reading config: %s", err)
}
}
if err := viper.Unmarshal(&conf); err != nil { if err := viper.Unmarshal(&conf); err != nil {
log.Fatalf("Error parsing config: %s", err) log.Fatalf("Error parsing config: %s", err)