From 080ce8e7819971a6cce6ce54c3f7cfc8c0692a7c 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 4a8811f37..b22620876 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).