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
viper.SetConfigFile(configPath)
if err := viper.ReadInConfig(); err != nil {
if _, ok := err.(viper.ConfigFileNotFoundError); ok {
log.Warnf("No config file found in search paths, using default values")
} else {
log.Fatalf("Error reading config: %s", err)
}
}
viper.SetEnvPrefix("speedtest")
viper.AutomaticEnv()
viper.ReadInConfig()
if err := viper.Unmarshal(&conf); err != nil {
log.Fatalf("Error parsing config: %s", err)