Skip to content

Instantly share code, notes, and snippets.

@perillo
Created December 4, 2015 13:47
Show Gist options
  • Save perillo/c32f01a4d2f0bede4b82 to your computer and use it in GitHub Desktop.
Save perillo/c32f01a4d2f0bede4b82 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"time"
)
func producer(ch chan<- int) {
ch <- 0
}
func producer_bad(ch chan<- int) {
consumer(ch)
}
func consumer(ch <-chan int) {
fmt.Println("consumed %d", <-ch)
}
func main() {
ch := make(chan int)
go producer(ch)
go producer_bad(ch)
time.Sleep(1 * time.Second)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment