Skip to content

Instantly share code, notes, and snippets.

@wingyplus
Created May 31, 2014 16:53
Show Gist options
  • Save wingyplus/235a7f8e141970be80a7 to your computer and use it in GitHub Desktop.
Save wingyplus/235a7f8e141970be80a7 to your computer and use it in GitHub Desktop.
package main
import "fmt"
func sender(to chan string, done chan bool) {
for {
select {
case t := <-to:
fmt.Println(t)
case <-done:
break
}
}
}
func main() {
strs := []string{
"a",
"b",
"c",
"d",
}
ch := make(chan string, len(strs))
done := make(chan bool)
go sender(ch, done)
for _, v := range strs {
ch <- v
}
done <- true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment