So far, we've looked at the most common concurrency patterns that can be used. Now, we will focus on some that are less common but are worth mentioning.
Other patterns
Error groups
The power of sync.WaitGroup is that it allows us to wait for simultaneous goroutines to finish their jobs. We have already looked at how sharing context can allow us to give the goroutines an early exit if it's used correctly. The first concurrent operation, such as send or receive from a channel, is in the select block, together with the context completion channel:
func main() {
ctx, canc := context.WithTimeout(context.Background(), time.Second)
defer canc()
wg := sync.WaitGroup{}
wg.Add(10)
var ch = make(chan int...