Skip to content

Commit

Permalink
feat: add env configuration support (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
onedr0p authored Apr 11, 2023
1 parent 4afbe82 commit fa28701
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit fa28701

Please sign in to comment.