From 69ad2a961cb71f87db51e8a40e2b4d1d086962fe Mon Sep 17 00:00:00 2001 From: Evan Chen Date: Fri, 12 Nov 2021 14:29:47 +0800 Subject: [PATCH] reorder --- file.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/file.go b/file.go index d93a6e7..604bd02 100644 --- a/file.go +++ b/file.go @@ -86,12 +86,15 @@ func (f *File) Do(CmdTimeout time.Duration) (string, error) { } f.owner.log.Info("DO: ", f.Cmd) done := make(chan string, 1) + var b bytes.Buffer + cmd.Stdout = &b + cmd.Stderr = &b + err := cmd.Start() + if err != nil { + f.owner.log.Error("cmd start error: ", err) + panic(err) + } go func() { - - var b bytes.Buffer - cmd.Stdout = &b - cmd.Stderr = &b - cmd.Start() f.pid = cmd.Process.Pid cmd.Wait() done <- b.String()