Home > Articles

This chapter is from the book

This chapter is from the book

Summary

In this chapter, we took a look at just a few of the synchronization types and functions in Go. First, we explored how to use a sync.WaitGroup to wait for a number of goroutines to finish. Then we explained how to use sync.ErrGroup to wait for a number of goroutines to finish and return an error if any of them failed. Next, we discussed how to use sync.Mutex and sync.RWMutex to synchronize access to a shared resource. Finally, we covered how to use sync.Once to ensure a function is only executed one time.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.