From a3cd8ab85aeba3522b9b59242f3b86ddbc67f8bd Mon Sep 17 00:00:00 2001 From: Elliot Morrison-Reed Date: Thu, 20 Apr 2017 15:35:06 +0200 Subject: [PATCH] Use os.Getenv("HOME") instead of "$HOME" for windows compatibility (#337) --- cobra/cmd/init.go | 4 ++-- cobra/cmd/root.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) 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 {