From eff08782cfb5f2bc497fdeaf0270668bbf6dff41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Sat, 21 May 2022 19:06:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E4=BC=A0=E5=85=A5=E7=9A=84?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E7=9B=AE=E5=BD=95=E4=B8=BA=E7=A9=BA=E7=9A=84?= =?UTF-8?q?=E5=9C=BA=E6=99=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- execute.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/execute.go b/execute.go index 8c334d3..83671f3 100644 --- a/execute.go +++ b/execute.go @@ -22,6 +22,7 @@ import ( // // Date : 21:49 2022/5/20 func Execute(workDir string, command string, param []string) define.Result { + //执行命令 result := define.Result{ WorkDir: workDir, @@ -33,6 +34,13 @@ func Execute(workDir string, command string, param []string) define.Result { defer func() { result.FinishTime = time.Now().UnixNano() }() + if len(workDir) == 0 { + // 默认为项目根目录 + result.WorkDir, result.Error = os.Getwd() + } + if nil != result.Error { + return result + } var ( fileInfo os.FileInfo )