Closed nicolasdilley closed 4 years ago
In this example the WaitGroup t.wg is declared automatically because the default value of a sync.WaitGroup is an empty WaitGroup not nil
type T struct { wg sync.Waitgroup }
func main () { t := T{} t.wg.Add(10)
for i := 0; i < 10; i ++ { go func(){ // Do some work t.wg.Done() } }
t.wg.Wait() }
In this example the WaitGroup t.wg is declared automatically because the default value of a sync.WaitGroup is an empty WaitGroup not nil
type T struct { wg sync.Waitgroup }
func main () { t := T{} t.wg.Add(10)
for i := 0; i < 10; i ++ { go func(){ // Do some work t.wg.Done() } }
t.wg.Wait() }