count = 20
chan = make(chan,20)
for循环 i = 20
go func()
优雅的处理任务:https://zhuanlan.zhihu.com/p/419781721
func TestAdd(t *testing.T) {
wg := sync.WaitGroup{}
c := make(chan int, 10)
for i := 0; i < 5; i++ {
wg.Add(1)
go func() {
defer wg.Done()
for {
v, ok := <- c
if !ok {
return
}
fmt.Println(v)
}
}()
}
for i := 0; i < 20; i++ {
c <- i
}
close(c)
wg.Wait()
}