diff --git a/README.md b/README.md index 63fb4bcb2..221546047 100644 --- a/README.md +++ b/README.md @@ -194,7 +194,6 @@ import ( "fmt" "os" - homedir "github.com/mitchellh/go-homedir" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -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 { diff --git a/cobra/cmd/root.go b/cobra/cmd/root.go index f27ae7e6c..aafbde207 100644 --- a/cobra/cmd/root.go +++ b/cobra/cmd/root.go @@ -15,8 +15,8 @@ package cmd import ( "fmt" + "os" - homedir "github.com/mitchellh/go-homedir" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -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). diff --git a/cobra/cmd/testdata/root.go.golden b/cobra/cmd/testdata/root.go.golden index dba491123..7df19f990 100644 --- a/cobra/cmd/testdata/root.go.golden +++ b/cobra/cmd/testdata/root.go.golden @@ -20,7 +20,6 @@ import ( "os" "github.com/spf13/cobra" - homedir "github.com/mitchellh/go-homedir" "github.com/spf13/viper" ) @@ -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). diff --git a/cobra/tpl/main.go b/cobra/tpl/main.go index 0b9c6610e..7d60fdd37 100644 --- a/cobra/tpl/main.go +++ b/cobra/tpl/main.go @@ -27,7 +27,6 @@ import ( "os" "github.com/spf13/cobra" {{ if .Viper }} - homedir "github.com/mitchellh/go-homedir" "github.com/spf13/viper"{{ end }} ) @@ -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).