(goctl): Use .goctl as home if not exists (#4260)

This commit is contained in:
kesonan 2024-07-19 13:54:24 +08:00 committed by GitHub
parent 4a14164be1
commit cf5b080fbe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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
}