* fix issue #831 * fix typo Co-authored-by: anqiansong <anqiansong@xiaoheiban.cn>
This commit is contained in:
@@ -17,6 +17,12 @@ const (
|
||||
goctlDir = ".goctl"
|
||||
)
|
||||
|
||||
var goctlHome string
|
||||
|
||||
func RegisterGoctlHome(home string) {
|
||||
goctlHome = home
|
||||
}
|
||||
|
||||
// CreateIfNotExist creates a file if it is not exists
|
||||
func CreateIfNotExist(file string) (*os.File, error) {
|
||||
_, err := os.Stat(file)
|
||||
@@ -62,6 +68,10 @@ func FileNameWithoutExt(file string) string {
|
||||
|
||||
// GetGoctlHome returns the path value of the goctl home where Join $HOME with .goctl
|
||||
func GetGoctlHome() (string, error) {
|
||||
if len(goctlHome) != 0 {
|
||||
return goctlHome, nil
|
||||
}
|
||||
|
||||
home, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
||||
Reference in New Issue
Block a user