diff --git a/git.go b/git.go index ba8a6e8..15035dc 100644 --- a/git.go +++ b/git.go @@ -231,6 +231,7 @@ func (g *git) Clone(repo string, saveDir string) *define.Result { // Author : go_developer@163.com<白茶清欢> // // Date : 22:15 2023/4/9 -func (g *git) Version() *define.Result { - return Execute(g.workDir, g.gitCmdPath, []string{"version"}) +func (g *git) Version() (string, error) { + r := Execute(g.workDir, g.gitCmdPath, []string{"version"}) + return string(r.Output), r.Error } diff --git a/golang.go b/golang.go index 2910877..6e3a13b 100644 --- a/golang.go +++ b/golang.go @@ -22,7 +22,10 @@ import ( // Date : 20:04 2022/5/22 func Golang(workDir string, goCmdPath string) *golang { if len(goCmdPath) == 0 { - goCmdPath = "go" + goCmdPath, _ = Check("go") + if len(goCmdPath) == 0 { + goCmdPath = "go" + } } return &golang{ workDir: workDir, @@ -146,7 +149,7 @@ func (g *golang) FormatCode() *define.Result { // // Date : 19:25 2022/6/26 func (g *golang) GetGoENV() define.GoENV { - result := Execute(g.workDir, "go", []string{"env"}) + result := Execute(g.workDir, g.goCmdPath, []string{"env"}) return g.FormatGoENV(string(result.Output)) } @@ -194,3 +197,13 @@ func (g *golang) SwagInit(param []string) *define.Result { swagCmdPath := envResult.GOPATH + "/bin/swag" return Execute(g.workDir, swagCmdPath, param) } + +// Version 获取版本信息 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 22:42 2023/4/9 +func (g *golang) Version() (string, error) { + result := Execute(g.workDir, g.goCmdPath, []string{"version"}) + return string(result.Output), result.Error +}