Skip to content
masterclass Buddy

Go · Class

sync.WaitGroup

sync.WaitGroup tracks unfinished goroutines or tasks. Call Go, or use Add and Done, then call Wait to block until the counter reaches zero.

Last updated

Syntax

type WaitGroup struct{}
func (wg *WaitGroup) Add(delta int)
func (wg *WaitGroup) Done()
func (wg *WaitGroup) Wait()
func (wg *WaitGroup) Go(f func())

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • sync.WaitGroup.Add
  • sync.WaitGroup.Done
  • sync.WaitGroup.Wait
  • sync.WaitGroup.Go

Source: The Go Programming Language — src/sync/waitgroup.go. Checked 2026-11-03.