Skip to content

Instantly share code, notes, and snippets.

@leonardo5621
Last active July 24, 2022 00:38
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/16a90032a12866803713acb30817f35f to your computer and use it in GitHub Desktop.
Save leonardo5621/16a90032a12866803713acb30817f35f 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)
isEven := func(x int) bool {
return x % 2 == 0
}
for num := range Filter(done, range10, isEven) {
fmt.Println(num)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment