Skip to content

Instantly share code, notes, and snippets.

@jrusev
Created April 8, 2017 13:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrusev/c624120fd4acd2698eefb32302d30a8d to your computer and use it in GitHub Desktop.
Save jrusev/c624120fd4acd2698eefb32302d30a8d to your computer and use it in GitHub Desktop.
package main
import "fmt"
import "time"
func f(in <-chan int, out chan<- int) {
for j := range in {
time.Sleep(time.Second)
out <- j * 2
}
}
func main() {
in := make(chan int, 100)
out := make(chan int, 100)
go f(in, out)
for j := 1; j <= 8; j++ {
in <- j
}
for a := 1; a <= 8; a++ {
fmt.Println(<-out)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment