// +build OMITpackagemainimport"fmt"// gen sends the values in nums on the returned channel, then closes it.funcgen(nums...int)<-chanint{out:=make(chanint)gofunc(){for_,n:=rangenums{out<-n}close(out)}()returnout}// sq receives values from in, squares them, and sends them on the returned// channel, until in is closed. Then sq closes the returned channel.funcsq(in<-chanint)<-chanint{out:=make(chanint)gofunc(){forn:=rangein{out<-n*n}close(out)}()returnout}funcmain(){// Set up the pipeline and consume the output.forn:=rangesq(sq(gen(2,3))){fmt.Println(n)// 16 then 81}}