优化返回结果

This commit is contained in:
zhangdeman committed 2022-05-20 22:31:29 +08:00
1 parent a015d2984d
commit d4e7b563bc
3 files changed
+7 -1

No files matched your search

+1 -1
View File
@@ -18,5 +18,5 @@
# vendor/
.idea
.vscode
mail_test.go
*_test.go
+2
View File
@@ -13,6 +13,8 @@ package define
//
// Date : 22:00 2022/5/20
type Result struct {
WorkDir string // 执行的目录
CmdPath string // 命令的路径
Err error // 异常信息
Output []byte // 输出的内容
StartTime int64 // 开始时间
+4
View File
@@ -22,6 +22,7 @@ import (
func Execute(workDir string, command string, param []string) define.Result {
//执行命令
result := define.Result{
WorkDir: workDir,
Err: nil,
Output: nil,
StartTime: time.Now().UnixNano(),
@@ -30,6 +31,9 @@ func Execute(workDir string, command string, param []string) define.Result {
defer func() {
result.FinishTime = time.Now().UnixNano()
}()
if result.CmdPath, result.Err = Check(command); nil != result.Err {
return result
}
cmdInstance := exec.Command(command, param...)
cmdInstance.Dir = workDir
result.Output, result.Err = cmdInstance.CombinedOutput()
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.