package main import ( "fmt" ) func main() { done := make(chan int) p := make(chan int) go func() { for i := 0; i < 5; i++ { p <- i } }() go func() { for { x := <- p done <- x * x } }() for i := 0; i < 5; i++ { fmt.Println(<-done) // 0, 1, 4, 9, 16 } }