This commit is contained in:
Christo De Lange 2017-04-19 13:42:09 +00:00 committed by GitHub
commit 110b3a666e
2 changed files with 8 additions and 8 deletions

View file

@ -205,13 +205,13 @@ func init() {
{{ if .viper }}
// initConfig reads in config file and ENV variables if set.
func initConfig() {
if cfgFile != "" { // enable ability to specify config file via flag
viper.SetConfigName(".{{ .appName }}") // name of config file (without extension)
viper.AddConfigPath("$HOME") // adding home directory as first search path
if cfgFile != "" { // enable ability to specify config file via flag
viper.SetConfigFile(cfgFile)
}
viper.SetConfigName(".{{ .appName }}") // name of config file (without extension)
viper.AddConfigPath("$HOME") // adding home directory as first search path
viper.AutomaticEnv() // read in environment variables that match
viper.AutomaticEnv() // read in environment variables that match
// If a config file is found, read it in.
if err := viper.ReadInConfig(); err == nil {

View file

@ -57,13 +57,13 @@ func init() {
// Read in config file and ENV variables if set.
func initConfig() {
if cfgFile != "" { // enable ability to specify config file via flag
viper.SetConfigName(".cobra") // name of config file (without extension)
viper.AddConfigPath("$HOME") // adding home directory as first search path
if cfgFile != "" { // enable ability to specify config file via flag
viper.SetConfigFile(cfgFile)
}
viper.SetConfigName(".cobra") // name of config file (without extension)
viper.AddConfigPath("$HOME") // adding home directory as first search path
viper.AutomaticEnv() // read in environment variables that match
viper.AutomaticEnv() // read in environment variables that match
// If a config file is found, read it in.
if err := viper.ReadInConfig(); err == nil {