From bd9a753bbe47ce9795506c795c74c98b9545a049 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Sun, 9 Apr 2023 22:52:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=91=BD=E4=BB=A4=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- execute.go | 2 ++ git.go | 9 +++++++++ golang.go | 9 +++++++++ 3 files changed, 20 insertions(+) diff --git a/execute.go b/execute.go index 1647390..0e669fd 100644 --- a/execute.go +++ b/execute.go @@ -11,6 +11,7 @@ import ( "errors" "os" "os/exec" + "strings" "time" "git.zhangdeman.cn/zhangdeman/command/define" @@ -63,6 +64,7 @@ func Execute(workDir string, command string, param []string) *define.Result { cmdInstance := exec.Command(command, param...) cmdInstance.Dir = result.WorkDir result.Output, result.Error = cmdInstance.CombinedOutput() + result.Output = []byte(strings.TrimRight(string(result.Output), `\n`)) return result } diff --git a/git.go b/git.go index 15035dc..f6bed0c 100644 --- a/git.go +++ b/git.go @@ -235,3 +235,12 @@ func (g *git) Version() (string, error) { r := Execute(g.workDir, g.gitCmdPath, []string{"version"}) return string(r.Output), r.Error } + +// GetPath 获取命令路径 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 22:49 2023/4/9 +func (g *git) GetPath() string { + return g.gitCmdPath +} diff --git a/golang.go b/golang.go index 6e3a13b..6b3d586 100644 --- a/golang.go +++ b/golang.go @@ -207,3 +207,12 @@ func (g *golang) Version() (string, error) { result := Execute(g.workDir, g.goCmdPath, []string{"version"}) return string(result.Output), result.Error } + +// GetPath 获取命令路径 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 22:49 2023/4/9 +func (g *golang) GetPath() string { + return g.goCmdPath +}