Generator Pattern

Learn about the generator pattern in Golang.

Overview of the generator pattern

We use a generator pattern to create a sequence of values that we can use to produce an output. A generator is a function that behaves like an iterator. In other words, it’s a function that launches a goroutine that produces data on a channel that it returns.

Get hands-on with 1400+ tech skills courses.