unix command pipeline on golang
out, err := Output(
[]string{"git", "log", "--oneline"},
[]string{"grep", "first import"},
[]string{"wc", "-l"},
)
if err != nil {
log.Fatal(err)
}
fmt.Println(string(out))
// Output:
// 1
out, _ = CombinedOutput(
[]string{"rmdir", "not_exist_dir"},
)
fmt.Println(string(out))
// Output:
// rmdir: failed to remove 'not_exist_dir': No such file or directory
$ go get github.com/mattn/go-pipeline
MIT
Yasuhiro Matsumoto (a.k.a mattn)