Skip to content

Commit

Permalink
(goctl): Use .goctl as home if not exists (#4260)
Browse files Browse the repository at this point in the history
  • Loading branch information
kesonan committed Jul 19, 2024
1 parent 4a14164 commit cf5b080
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tools/goctl/util/pathx/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit cf5b080

Please sign in to comment.