box-o-sand/gotime/gotour-artifacts/buffered-channels/main.go
Dan Buch 44999623da Collapsing tree into more sane Go project layout
since I was in here looking at something unrelated...
2012-12-13 18:12:43 -05:00

30 lines
341 B
Go

package main
import (
"fmt"
"time"
)
func main() {
c := make(chan int, 2)
q := make(chan bool)
go func(c chan int) {
for i := range c {
fmt.Println("\t", i, "<- popped")
time.Sleep(300 * time.Millisecond)
}
}(c)
go func(c chan int) {
i := 0
for {
c <- i
fmt.Println("pushed ->", i)
i += 1
}
}(c)
<-q
}