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 }}") }