Skip to content
Myr

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

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Elliot Morrison-Reed · committed by Albert Nigmatzianov · parent b655df6 · Browse files · 2 files+5 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+5 added−5 removed

  • other:+5 added−5 removed

2 files+5 added−5 removed

modified:cobra/cmd/init.go+2 added-2 removed
208 unmodified lines
209 viper.SetConfigFile(cfgFile)210 }211212 viper.SetConfigName(".{{ .appName }}") // name of config file (without extension)213 viper.AddConfigPath("$HOME") // adding home directory as first search path214 viper.AutomaticEnv() // read in environment variables that match213 viper.AddConfigPath(os.Getenv("HOME")) // adding home directory as first search path214 viper.AutomaticEnv() // read in environment variables that match215216 // If a config file is found, read it in.217 if err := viper.ReadInConfig(); err == nil {218 fmt.Println("Using config file:", viper.ConfigFileUsed())
27 unmodified lines
modified:cobra/cmd/root.go+3 added-3 removed
59 unmodified lines
60 if cfgFile != "" { // enable ability to specify config file via flag61 viper.SetConfigFile(cfgFile)62 }6364 viper.SetConfigName(".cobra") // name of config file (without extension)65 viper.AddConfigPath("$HOME") // adding home directory as first search path66 viper.AutomaticEnv() // read in environment variables that match64 viper.SetConfigName(".cobra") // name of config file (without extension)65 viper.AddConfigPath(os.Getenv("HOME")) // adding home directory as first search path66 viper.AutomaticEnv() // read in environment variables that match6768 // If a config file is found, read it in.69 if err := viper.ReadInConfig(); err == nil {70 fmt.Println("Using config file:", viper.ConfigFileUsed())
2 unmodified lines