Created
May 21, 2020 13:40
-
-
Save RicardoLinck/a9ec802cf40ccba19a16a6e0a90a02c9 to your computer and use it in GitHub Desktop.
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 characters
package main | |
import "fmt" | |
func main() { | |
c := make(chan int) | |
q := 10 | |
go generateInts(c, q) | |
for i := range c { | |
fmt.Println(i) | |
} | |
} | |
func generateInts(c chan int, q int) { | |
for i := 0; i < q; i++ { | |
c <- i | |
} | |
close(c) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment