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