equal
deleted
inserted
replaced
168 // initConfig reads in config file and ENV variables if set. |
168 // initConfig reads in config file and ENV variables if set. |
169 func initConfig() { |
169 func initConfig() { |
170 if cfgFile == "/dev/null" { |
170 if cfgFile == "/dev/null" { |
171 return |
171 return |
172 } |
172 } |
173 if cfgFile != "" { // enable ability to specify config file via flag |
|
174 viper.SetConfigFile(cfgFile) |
|
175 } |
|
176 |
173 |
177 viper.SetConfigName(AppName) // name of config file (without extension) |
174 viper.SetConfigName(AppName) // name of config file (without extension) |
178 viper.AddConfigPath("$HOME/.config/" + AppName) |
175 viper.AddConfigPath("$HOME/.config/" + AppName) |
179 viper.AddConfigPath("$HOME/." + AppName) |
176 viper.AddConfigPath("$HOME/." + AppName) |
180 |
177 |
181 // Read in environment variables that match, with a prefix |
178 // Read in environment variables that match, with a prefix |
182 viper.SetEnvPrefix(AppName) |
179 viper.SetEnvPrefix(AppName) |
183 viper.AutomaticEnv() |
180 viper.AutomaticEnv() |
|
181 |
|
182 // Enable ability to specify config file via flag |
|
183 viper.SetConfigFile(cfgFile) |
184 |
184 |
185 // If a config file is found, read it in. |
185 // If a config file is found, read it in. |
186 err := viper.ReadInConfig() |
186 err := viper.ReadInConfig() |
187 if err != nil { |
187 if err != nil { |
188 if cfgFile != "" { |
188 if cfgFile != "" { |