Skip to content

Instantly share code, notes, and snippets.

@Omie
Created February 12, 2015 22:29
Show Gist options
  • Save Omie/52add99f6685dcb340a1 to your computer and use it in GitHub Desktop.
Save Omie/52add99f6685dcb340a1 to your computer and use it in GitHub Desktop.
package main
import (
"log"
"time"
)
var foo chan int
func fillFoo() {
for i := 0; i < 20; i++ {
//this will get blocked beyond 15
foo <- i
log.Println("pushed", i)
}
close(foo)
}
func main() {
foo = make(chan int, 15)
go fillFoo()
for {
bar := <-foo
log.Println("popped", bar)
time.Sleep(2 * time.Second)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment