Share your repls and programming experiences

← Back to all posts
Concurrency: Fan out using goroutines and channels
judwhite1 (1)

One way to fan out work in a single process.

This program:

  • reads your input from stdin
  • sends input to a channel
  • goroutine sends that input to 3 other channels
  • those goroutines do a transformation (upper, funky, reverse) on the original input
  • note you'll occasionally see 'upper', 'funky', 'reverse' output in a different order because they're executed on separate goroutines