Visual representation of Go's producer-consumer pattern
func producer(ch chan int) { for i := 1; i <= 5; i++ { fmt.Println("Producing data:", i) ch <- i // Send data to channel } close(ch) } func consumer(ch chan int) { for v := range ch { fmt.Println("Consuming data:", v) } } func main() { ch := make(chan int, 3) go producer(ch) go consumer(ch) }