Skip to content

Instantly share code, notes, and snippets.

@JosephShering
Created May 26, 2017 14:15
Show Gist options
  • Save JosephShering/c46422732a71416fb3fccc682bc64ae1 to your computer and use it in GitHub Desktop.
Save JosephShering/c46422732a71416fb3fccc682bc64ae1 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
)
func main() {
out := make(chan string, 2)
in := make(chan string, 2)
go handle(in, out)
in <- "http://www.facebook.com"
in <- "http://www.github.com"
in <- "http://scotch.io"
close(in)
for link := range out {
fmt.Println(link)
}
}
func handle(in <-chan string, out chan<- string) {
out <- "http://yahoo.com"
for i := range in {
fmt.Println(i)
}
out <- "http://google.com"
close(out)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment