awaitgroup
A WaitGroup waits for a collection of async tasks to finish.
The main task can create new workers and pass them to each of the tasks it wants to wait for. Each of the tasks calls done when
it finishes executing, and the main task can call wait to block until all registered workers are done.
use WaitGroup;
async
See the documentation for more details.