Use os.Getenv("HOME") instead of "$HOME" for windows compatibility

This commit is contained in:
Elliot Morrison-Reed 2016-08-26 21:49:38 +02:00
parent 37c3f80603
commit c888c97288
2 changed files with 2 additions and 2 deletions

View file

@ -210,7 +210,7 @@ func initConfig() {
} }
viper.SetConfigName(".{{ .appName }}") // name of config file (without extension) viper.SetConfigName(".{{ .appName }}") // name of config file (without extension)
viper.AddConfigPath("$HOME") // adding home directory as first search path viper.AddConfigPath(os.Getenv("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 a config file is found, read it in.

View file

@ -62,7 +62,7 @@ func initConfig() {
} }
viper.SetConfigName(".cobra") // name of config file (without extension) viper.SetConfigName(".cobra") // name of config file (without extension)
viper.AddConfigPath("$HOME") // adding home directory as first search path viper.AddConfigPath(os.Getenv("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 a config file is found, read it in.