コード風プロンプト例5h Goのgoroutine:パイプラインパターン
Executes Go-style pipeline pattern and outputs fooX barX baz
/plugin marketplace add kokuyouwind/claude-plugins/plugin install code-like-prompt@kokuyouwind-pluginsEmulate the following Go-style code internally (without using external tools or interpreter). Output only what fmt.Println() commands would output. Do not show any explanations, code, variables, or other messages.
package main
import "fmt"
func stage1(out chan<- string) {
out <- "foo"
out <- "bar"
close(out)
}
func stage2(in <-chan string, out chan<- string) {
for s := range in {
out <- s + "X"
}
close(out)
}
func main() {
ch1 := make(chan string)
ch2 := make(chan string)
go stage1(ch1)
go stage2(ch1, ch2)
for result := range ch2 {
fmt.Println(result)
}
fmt.Println("baz")
}