From 713fc392d79c1568f37b053fce8361ac860e27ae Mon Sep 17 00:00:00 2001 From: Rob Playford Date: Wed, 25 Nov 2020 15:54:05 +0000 Subject: [PATCH] fix home directory config not loading --- README.md | 1 + cobra/cmd/root.go | 1 + cobra/cmd/testdata/root.go.golden | 1 + cobra/tpl/main.go | 1 + 4 files changed, 4 insertions(+) diff --git a/README.md b/README.md index 3cf1b25d8..dbf95f21a 100644 --- a/README.md +++ b/README.md @@ -252,6 +252,7 @@ func initConfig() { // Search config in home directory with name ".cobra" (without extension). viper.AddConfigPath(home) + viper.SetConfigType("yaml") viper.SetConfigName(".cobra") } diff --git a/cobra/cmd/root.go b/cobra/cmd/root.go index 97f404bbb..038444a3f 100644 --- a/cobra/cmd/root.go +++ b/cobra/cmd/root.go @@ -69,6 +69,7 @@ func initConfig() { // Search config in home directory with name ".cobra" (without extension). viper.AddConfigPath(home) + viper.SetConfigType("yaml") viper.SetConfigName(".cobra") } diff --git a/cobra/cmd/testdata/root.go.golden b/cobra/cmd/testdata/root.go.golden index 1db829c71..3e2ca72cd 100644 --- a/cobra/cmd/testdata/root.go.golden +++ b/cobra/cmd/testdata/root.go.golden @@ -79,6 +79,7 @@ func initConfig() { // Search config in home directory with name ".testproject" (without extension). viper.AddConfigPath(home) + viper.SetConfigType("yaml") viper.SetConfigName(".testproject") } diff --git a/cobra/tpl/main.go b/cobra/tpl/main.go index 4348e5616..9e7851ae9 100644 --- a/cobra/tpl/main.go +++ b/cobra/tpl/main.go @@ -93,6 +93,7 @@ func initConfig() { // Search config in home directory with name ".{{ .AppName }}" (without extension). viper.AddConfigPath(home) + viper.SetConfigType("yaml") viper.SetConfigName(".{{ .AppName }}") }