Skip to content

Commit

Permalink
fix home directory config not loading (#1282)
Browse files Browse the repository at this point in the history
leverage `viper.SetConfigType("yaml")` to fix issue regarding home directory configuration failing to load.
  • Loading branch information
timecode committed Jun 16, 2021
1 parent 4590150 commit 9a43267
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -246,6 +246,7 @@ func initConfig() {

// Search config in home directory with name ".cobra" (without extension).
viper.AddConfigPath(home)
viper.SetConfigType("yaml")
viper.SetConfigName(".cobra")
}

Expand Down
1 change: 1 addition & 0 deletions cobra/cmd/root.go
Expand Up @@ -67,6 +67,7 @@ func initConfig() {

// Search config in home directory with name ".cobra" (without extension).
viper.AddConfigPath(home)
viper.SetConfigType("yaml")
viper.SetConfigName(".cobra")
}

Expand Down
1 change: 1 addition & 0 deletions cobra/cmd/testdata/root.go.golden
Expand Up @@ -73,6 +73,7 @@ func initConfig() {

// Search config in home directory with name ".testproject" (without extension).
viper.AddConfigPath(home)
viper.SetConfigType("yaml")
viper.SetConfigName(".testproject")
}

Expand Down
1 change: 1 addition & 0 deletions cobra/tpl/main.go
Expand Up @@ -86,6 +86,7 @@ func initConfig() {
// Search config in home directory with name ".{{ .AppName }}" (without extension).
viper.AddConfigPath(home)
viper.SetConfigType("yaml")
viper.SetConfigName(".{{ .AppName }}")
}
Expand Down

0 comments on commit 9a43267

Please sign in to comment.