diff --git a/cobra/cmd/init.go b/cobra/cmd/init.go index 13792f1..b77c986 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 065c8bf..32386ac 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 {