Skip to content

Commit

Permalink
drop mitchellh/go-homedir (spf13#853)
Browse files Browse the repository at this point in the history
  • Loading branch information
umarcor committed Oct 14, 2020
1 parent a3b3f22 commit 3a9ba67
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 9 deletions.
4 changes: 1 addition & 3 deletions README.md
Expand Up @@ -194,7 +194,6 @@ import (
"fmt"
"os"

homedir "github.com/mitchellh/go-homedir"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
Expand Down Expand Up @@ -240,14 +239,13 @@ func initConfig() {
viper.SetConfigFile(cfgFile)
} else {
// Find home directory.
home, err := homedir.Dir()
home, err := os.UserHomeDir()
cobra.CheckErr(err)

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

viper.AutomaticEnv()

if err := viper.ReadInConfig(); err == nil {
Expand Down
4 changes: 2 additions & 2 deletions cobra/cmd/root.go
Expand Up @@ -15,8 +15,8 @@ package cmd

import (
"fmt"
"os"

homedir "github.com/mitchellh/go-homedir"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
Expand Down Expand Up @@ -62,7 +62,7 @@ func initConfig() {
viper.SetConfigFile(cfgFile)
} else {
// Find home directory.
home, err := homedir.Dir()
home, err := os.UserHomeDir()
cobra.CheckErr(err)

// Search config in home directory with name ".cobra" (without extension).
Expand Down
3 changes: 1 addition & 2 deletions cobra/cmd/testdata/root.go.golden
Expand Up @@ -20,7 +20,6 @@ import (
"os"
"github.com/spf13/cobra"

homedir "github.com/mitchellh/go-homedir"
"github.com/spf13/viper"
)

Expand Down Expand Up @@ -68,7 +67,7 @@ func initConfig() {
viper.SetConfigFile(cfgFile)
} else {
// Find home directory.
home, err := homedir.Dir()
home, err := os.UserHomeDir()
cobra.CheckErr(err)

// Search config in home directory with name ".testproject" (without extension).
Expand Down
3 changes: 1 addition & 2 deletions cobra/tpl/main.go
Expand Up @@ -27,7 +27,6 @@ import (
"os"
"github.com/spf13/cobra"
{{ if .Viper }}
homedir "github.com/mitchellh/go-homedir"
"github.com/spf13/viper"{{ end }}
)
Expand Down Expand Up @@ -81,7 +80,7 @@ func initConfig() {
viper.SetConfigFile(cfgFile)
} else {
// Find home directory.
home, err := homedir.Dir()
home, err := os.UserHomeDir()
cobra.CheckErr(err)
// Search config in home directory with name ".{{ .AppName }}" (without extension).
Expand Down

0 comments on commit 3a9ba67

Please sign in to comment.