Created
December 22, 2017 13:17
-
-
Save kovacshuni/59f2ad36666674f7d81144d33c1c7fa8 to your computer and use it in GitHub Desktop.
feeding-printing-channels
This file contains 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 characters
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