github.com/serversong/goreporter@v0.0.0-20200325104552-3cfaf44fd178/linters/staticcheck/testdata/CheckWaitgroupAdd.go (about) 1 package pkg 2 3 import ( 4 "sync" 5 ) 6 7 func fn() { 8 wg := sync.WaitGroup{} 9 wg.Add(1) 10 go func() { 11 wg.Done() 12 }() 13 14 go func() { 15 wg.Add(1) // MATCH "should call wg.Add(1) before starting" 16 wg.Done() 17 }() 18 19 wg.Add(1) 20 go func(wg sync.WaitGroup) { 21 wg.Done() 22 }(wg) 23 24 wg.Add(1) 25 go func(wg *sync.WaitGroup) { 26 wg.Done() 27 }(&wg) 28 29 wg.Wait() 30 } 31 32 func fn2(wg sync.WaitGroup) { 33 wg.Add(1) 34 }