github.com/pubgo/xprocess@v0.1.11/xprocess_group/group_test.go (about) 1 package xprocess_group 2 3 import ( 4 "context" 5 "fmt" 6 "testing" 7 "time" 8 ) 9 10 func TestGroup(t *testing.T) { 11 g := New(5) 12 for i := 30; i > 0; i-- { 13 i := i 14 g.Go(func(ctx context.Context) { 15 fmt.Println("ok", i) 16 time.Sleep(time.Second * 2) 17 }) 18 } 19 g.Wait() 20 time.Sleep(time.Second * 2) 21 }