diff --git a/cobra/cmd/init.go b/cobra/cmd/init.go index 13792f12..b77c9864 100644 --- a/cobra/cmd/init.go +++ b/cobra/cmd/init.go @@ -210,8 +210,8 @@ func initConfig() { } 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.AddConfigPath(os.Getenv("HOME")) // adding home directory as first search path + viper.AutomaticEnv() // read in environment variables that match // If a config file is found, read it in. if err := viper.ReadInConfig(); err == nil { diff --git a/cobra/cmd/root.go b/cobra/cmd/root.go index 065c8bf4..32386ace 100644 --- a/cobra/cmd/root.go +++ b/cobra/cmd/root.go @@ -61,9 +61,9 @@ func initConfig() { 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.SetConfigName(".cobra") // name of config file (without extension) + viper.AddConfigPath(os.Getenv("HOME")) // adding home directory as first search path + viper.AutomaticEnv() // read in environment variables that match // If a config file is found, read it in. if err := viper.ReadInConfig(); err == nil {