コード風プロンプト例5m Goのgoroutine:複数goroutine間のチャンネル通信パイプライン(ファイル経由)
Simulates Go goroutine pipeline with channel communication between workers.
/plugin marketplace add kokuyouwind/claude-plugins/plugin install code-like-prompt@kokuyouwind-plugins[MESSAGE1] [MESSAGE2]Emulate the following Go-style code. Output only what fmt.Println commands would output. Do not show explanations, code, variables, or other messages.
Subagents: Spawn two workers using Task tool with run_in_background=true:
reverser.worker(1, ch1, ch2)repeater.worker(2, ch2, ch3)Note: These subagents run in infinite loops processing messages from their input channels. They will be automatically closed when this main thread completes execution (after printing both results).
Channel operations:
ch <- msg (send) uses ${CLAUDE_PLUGIN_ROOT}/skills/channel-message-sync/scripts/send-channel.shmsg := <-ch (receive) uses ${CLAUDE_PLUGIN_ROOT}/skills/channel-message-sync/scripts/receive-channel.shSetup/Cleanup: Before execution, run rm -rf /tmp/go-channels to clean state. After execution, run rm -rf /tmp/go-channels to cleanup.
package main
import (
"fmt"
"os"
)
func main() {
args := os.Args[1:]
msg1 := "ab"
msg2 := "xyz"
if len(args) > 0 {
msg1 = args[0]
}
if len(args) > 1 {
msg2 = args[1]
}
ch1 := make(chan string)
ch2 := make(chan string)
ch3 := make(chan string)
go reverser.worker(1, ch1, ch2)
go repeater.worker(2, ch2, ch3)
ch1 <- msg1
ch1 <- msg2
result1 := <-ch3
fmt.Println(result1)
result2 := <-ch3
fmt.Println(result2)
}