From 2c6346468a14c7468851cdaff5adb2824a50ae94 Mon Sep 17 00:00:00 2001 From: umarcor Date: Fri, 7 Jun 2019 21:48:51 +0200 Subject: [PATCH] drop mitchellh/go-homedir (#853) --- README.md | 4 +--- cobra/cmd/root.go | 4 ++-- cobra/cmd/testdata/root.go.golden | 3 +-- cobra/tpl/main.go | 3 +-- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 24bbe1a7e8..aa5c7c81ab 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 f27ae7e6cf..aafbde207d 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 dba491123b..7df19f990d 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 0b9c6610e3..7d60fdd373 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).