diff --git a/cobra/cmd/root.go b/cobra/cmd/root.go index 065c8bf4..c059c81f 100644 --- a/cobra/cmd/root.go +++ b/cobra/cmd/root.go @@ -57,12 +57,13 @@ func init() { // Read in config file and ENV variables if set. func initConfig() { + viper.SetConfigName(".cobra") // name of config file (without extension) + viper.AddConfigPath("$HOME") // adding home directory as first search path + if cfgFile != "" { // enable ability to specify config file via flag 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 // If a config file is found, read it in.