github.com/fzfile/BaiduPCS-Go@v0.0.0-20200606205115-4408961cf336/pcsutil/waitgroup/wait_group_test.go (about) 1 package waitgroup 2 3 import ( 4 "fmt" 5 "testing" 6 "time" 7 ) 8 9 func TestWg(t *testing.T) { 10 wg := NewWaitGroup(2) 11 for i := 0; i < 60; i++ { 12 wg.AddDelta() 13 go func(i int) { 14 fmt.Println(i, wg.Parallel()) 15 time.Sleep(1e9) 16 wg.Done() 17 }(i) 18 } 19 wg.Wait() 20 }