本文整理匯總了Golang中github.com/ghemawat/stream.Run函數的典型用法代碼示例。如果您正苦於以下問題:Golang Run函數的具體用法?Golang Run怎麽用?Golang Run使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Run函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ExampleCommand_withError
func ExampleCommand_withError() {
err := stream.Run(stream.Command("no_such_command"))
if err == nil {
fmt.Println("execution of missing command succeeded unexpectedly")
}
// Output:
}
示例2: ExampleFind_error
func ExampleFind_error() {
err := stream.Run(stream.Find("/no_such_dir"))
if err == nil {
fmt.Println("stream.Find did not return expected error")
}
// Output:
}
示例3: ExampleSample
func ExampleSample() {
stream.Run(
stream.Numbers(100, 200),
stream.Sample(4),
stream.WriteLines(os.Stdout),
)
// Output not checked since it is non-deterministic.
}
示例4: BenchmarkFive
func BenchmarkFive(b *testing.B) {
f := stream.FilterFunc(func(arg stream.Arg) error {
for s := range arg.In {
arg.Out <- s
}
return nil
})
stream.Run(stream.Repeat("", b.N), f, f, f, f)
}
示例5: ExampleXargs
func ExampleXargs() {
stream.Run(
stream.Numbers(1, 5),
stream.Xargs("echo"),
stream.WriteLines(os.Stdout),
)
// Output:
// 1 2 3 4 5
}
示例6: ExampleItems
func ExampleItems() {
stream.Run(
stream.Items("hello", "world"),
stream.WriteLines(os.Stdout),
)
// Output:
// hello
// world
}
示例7: ExampleCommand
func ExampleCommand() {
stream.Run(
stream.Numbers(1, 100),
stream.Command("wc", "-l"),
stream.WriteLines(os.Stdout),
)
// Output:
// 100
}
示例8: ExampleCat
func ExampleCat() {
stream.Run(
stream.Cat("stream_test.go"),
stream.Grep("^func ExampleCat"),
stream.WriteLines(os.Stdout),
)
// Output:
// func ExampleCat() {
}
示例9: ExampleColumns
func ExampleColumns() {
stream.Run(
stream.Items("hello world"),
stream.Columns(2, 3, 1),
stream.WriteLines(os.Stdout),
)
// Output:
// world hello
}
示例10: ExampleNumberLines
func ExampleNumberLines() {
stream.Run(
stream.Items("a", "b"),
stream.NumberLines(),
stream.WriteLines(os.Stdout),
)
// Output:
// 1 a
// 2 b
}
示例11: ExampleWriteLines
func ExampleWriteLines() {
stream.Run(
stream.Numbers(1, 3),
stream.WriteLines(os.Stdout),
)
// Output:
// 1
// 2
// 3
}
示例12: ExampleFindFilter_SkipDirIf
func ExampleFindFilter_SkipDirIf() {
stream.Run(
stream.Find(".").SkipDirIf(func(d string) bool { return d == ".git" }),
stream.Grep("x"),
stream.WriteLines(os.Stdout),
)
// Output:
// regexp.go
// xargs.go
}
示例13: ExampleFind
func ExampleFind() {
stream.Run(
stream.Find(".").IfMode(os.FileMode.IsRegular),
stream.Grep("stream"),
stream.WriteLines(os.Stdout),
)
// Output:
// stream.go
// stream_test.go
}
示例14: ExampleDropFirst
func ExampleDropFirst() {
stream.Run(
stream.Numbers(1, 10),
stream.DropFirst(8),
stream.WriteLines(os.Stdout),
)
// Output:
// 9
// 10
}
示例15: ExampleLast
func ExampleLast() {
stream.Run(
stream.Numbers(1, 10),
stream.Last(2),
stream.WriteLines(os.Stdout),
)
// Output:
// 9
// 10
}