util/io: add RedirectStderr
All checks were successful
lint / lint (pull_request) Successful in 46s
pr / test (pull_request) Successful in 50s

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2023-04-24 12:58:05 +03:00
parent 814b90efe5
commit af278bd7d3
4 changed files with 137 additions and 0 deletions

17
util/io/redirect.go Normal file
View File

@@ -0,0 +1,17 @@
package io
import (
"os"
"sync"
)
var osStderrMu sync.Mutex
var OrigStderr = func() *os.File {
fd, err := dupFD(os.Stderr.Fd())
if err != nil {
panic(err)
}
return os.NewFile(fd, os.Stderr.Name())
}()