fix: close captureOutput pipe before read
This commit is contained in:
@@ -44,15 +44,14 @@ func captureOutput(fn func()) string {
|
|||||||
r, w, _ := os.Pipe()
|
r, w, _ := os.Pipe()
|
||||||
os.Stdout = w
|
os.Stdout = w
|
||||||
|
|
||||||
defer func() {
|
fn()
|
||||||
|
|
||||||
_ = w.Close()
|
_ = w.Close()
|
||||||
os.Stdout = old
|
os.Stdout = old
|
||||||
}()
|
|
||||||
|
|
||||||
fn()
|
|
||||||
|
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
_, _ = io.Copy(&buf, r)
|
_, _ = io.Copy(&buf, r)
|
||||||
|
_ = r.Close()
|
||||||
return buf.String()
|
return buf.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user