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 }