From d3b280a7e5d83be92ecb5e07b586dd974994373e Mon Sep 17 00:00:00 2001 From: Dreamacro <305009791@qq.com> Date: Thu, 28 Mar 2019 18:20:19 +0800 Subject: [PATCH] Fix: reuse Current.HomeDir until go 1.13 release --- constant/path.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/constant/path.go b/constant/path.go index 5d08e36c..32c67aad 100644 --- a/constant/path.go +++ b/constant/path.go @@ -2,6 +2,7 @@ package constant import ( "os" + "os/user" P "path" ) @@ -15,9 +16,16 @@ type path struct { } func init() { - homedir, err := os.UserHomeDir() + currentUser, err := user.Current() + var homedir string if err != nil { - homedir, _ = os.Getwd() + dir := os.Getenv("HOME") + if dir == "" { + dir, _ = os.Getwd() + } + homedir = dir + } else { + homedir = currentUser.HomeDir } homedir = P.Join(homedir, ".config", Name)