Skip to content

Instantly share code, notes, and snippets.

@kovacshuni
Created December 22, 2017 13:17
Show Gist options
  • Save kovacshuni/59f2ad36666674f7d81144d33c1c7fa8 to your computer and use it in GitHub Desktop.
Save kovacshuni/59f2ad36666674f7d81144d33c1c7fa8 to your computer and use it in GitHub Desktop.
feeding-printing-channels
package main
import (
"fmt"
"time"
)
func main() {
q := make(chan string, 1)
go func() {
for i := 0; i < 10; i++ {
q <- "hey "
time.Sleep(100 * time.Millisecond)
}
close(q)
}()
for a := range q {
fmt.Println(a)
}
fmt.Println("End.")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment