Created
April 8, 2017 13:31
-
-
Save jrusev/c624120fd4acd2698eefb32302d30a8d to your computer and use it in GitHub Desktop.
Revisions
-
jrusev created this gist
Apr 8, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ 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) } }