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