Waiting for Goroutines with sync.WaitGroup and errgroup.Group

Go makes it easy to run code in parallel with goroutines. To wait for them to finish, you can use sync.WaitGroup or errgroup.Group. This post explains how to use both and when to choose one over the other.