From cf5b080fbecd2e179b81d9530f5876f3d857ae68 Mon Sep 17 00:00:00 2001 From: kesonan Date: Fri, 19 Jul 2024 13:54:24 +0800 Subject: [PATCH] (goctl): Use .goctl as home if not exists (#4260) --- tools/goctl/util/pathx/file.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/goctl/util/pathx/file.go b/tools/goctl/util/pathx/file.go index 50823b397..778ecd69a 100644 --- a/tools/goctl/util/pathx/file.go +++ b/tools/goctl/util/pathx/file.go @@ -98,11 +98,12 @@ func GetGoctlHome() (home string, err error) { // GetDefaultGoctlHome returns the path value of the goctl home where Join $HOME with .goctl. func GetDefaultGoctlHome() (string, error) { + var goctlHomeDir = goctlDir home, err := os.UserHomeDir() - if err != nil { - return "", err + if err == nil { + goctlHomeDir = filepath.Join(home, goctlDir) } - goctlHomeDir := filepath.Join(home, goctlDir) + _ = MkdirIfNotExist(goctlHomeDir) return goctlHomeDir, nil }