Ai
1 Star 0 Fork 0

smartos-club/triton-kubernetes

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
alter.go 521 Bytes
一键复制 编辑 原始数据 按行查看 历史
Nirav Patel 提交于 2018-04-19 00:27 +08:00 . Enhance version module
package test_pkg
import (
"io/ioutil"
"os"
)
func AlterStdout(f func()) (<-chan []byte, <-chan error) {
errch := make(chan error)
outch := make(chan []byte)
oldstdout := os.Stdout
r, w, err := os.Pipe()
if err != nil {
go func() { errch <- err }()
return outch, errch
}
os.Stdout = w
f()
os.Stdout = oldstdout
go func() {
alteredStdout, err := ioutil.ReadAll(r)
defer r.Close()
if err != nil {
errch <- err
return
}
outch <- alteredStdout
}()
w.Close()
return outch, errch
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/smartos-club/triton-kubernetes.git
git@gitee.com:smartos-club/triton-kubernetes.git
smartos-club
triton-kubernetes
triton-kubernetes
v0.9.1

搜索帮助