Generators, wait groups and closures in Golang
·5 mins
This is the first step of my intention to write a series of articles where I would explain some common patterns used in Golang. Let’s start with generator pattern :
1type Generator func() <-chan int Generator is a function or method which returns a sequence of values. In Golang, this usually means returning a channel of values of desired type. In our example, we will return a channel of integers. Let’s see an implementation of this:
