该包使得 Go 应用程序能够像 Unix 中的 pipe 一样使用。
The pipe Go package offers an easy way for Go programs to make use of other applications available in the system via a Unix-like pipeline mechanism. The input and output streams in such pipelines do work as streams, so large content can go across the pipeline without being loaded entirely in memory.
The following blog post introduces the concept:
http://blog.labix.org/2013/04/15/unix-like-pipelines-for-go
简单例子:
```go
package main
import (
"fmt"
"gopkg.in/pipe.v2"
)
func main() {
p := pipe.Line(
pipe.ReadFile("article.ps"),
pipe.Exec("lpr"),
)
output, err := pipe.CombinedOutput(p)
if err != nil {
fmt.Printf("%v\n", err)
}
fmt.Printf("%s", output)
}
```
0 回复
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传