Skip to content

Instantly share code, notes, and snippets.

@leonardo5621
Last active July 24, 2022 00:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leonardo5621/6c8cb9597e37a4c4502a107efe19a0b2 to your computer and use it in GitHub Desktop.
Save leonardo5621/6c8cb9597e37a4c4502a107efe19a0b2 to your computer and use it in GitHub Desktop.
func main() {
done := make(chan struct{})
defer close(done)
// Generates a channel sending integers
// From 0 to 9
range10 := rangeChannel(done, 10)
for num := range takeFirstN(done, range10, 5) {
fmt.Println(num)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment