WaitGroups

In this lesson, you will learn about the WaitGroups present in the "sync" package which will allow us some control over goroutines.

We'll cover the following...

What is a WaitGroup?

A WaitGroup blocks a program and waits for a set of goroutines to finish before moving to the next steps of execution.

How to use WaitGroup?

We can use WaitGroups through the following functions:

  • .Add(int): This function takes in an integer value which is essentially the number of goroutines which the waitgroup has to wait for. This function must be called before we execute a goroutine.
  • .Done(): This function is called within the goroutine to signal that the goroutine
...
Access this course and 1400+ top-rated courses and projects.