Skip to content

Instantly share code, notes, and snippets.

@just1689
Last active April 8, 2018 11:20
Show Gist options
  • Save just1689/72facfc75ac86556814a906f42227812 to your computer and use it in GitHub Desktop.
Save just1689/72facfc75ac86556814a906f42227812 to your computer and use it in GitHub Desktop.
Process a channel of input and write results to a channel
func sq(in <-chan int) <-chan int {
out := make(chan int)
go func() {
for n := range in {
out <- n * n
}
close(out)
}()
return out
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment