支持命令路径获取
This commit is contained in:
parent
4d4b871d4d
commit
bd9a753bbe
@ -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
|
||||
}
|
||||
|
||||
|
9
git.go
9
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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user