Iterators and generators are essential to Go. Utilizing channels and goroutines for parallelism and concurrency is idiomatic in Go and is one of the best ways to write high-performance, readable code in the language. We are going to first talk about some of the basic Go constructs in order to be able to understand how to use iterators and generators in the context of Go, followed by deep dives into the constructs of the available iterators and generators of the language.
In this chapter, we are going to cover the following topics:
- Closures
- Goroutines
- Channels
- Semaphores
- WaitGroups
- Iterators
- Generators
Being able to understand the basic constructs of the Go language and when and where to use the proper iterators and generators is essential to writing performant Go.