
test script 1func gen(nums ...int) <-chan int { 2 out := make(chan int) 3 go func() { 4 for _, n := range nums { 5 out <- n 6 } 7 close(out) 8 }() 9 return out 10} 11func sq(in <-chan int) <-chan int { 12 out := make(chan int) 13 go func() { 14 for n := range in { 15 out <- n * n 16 } 17 close(out) 18 …