goroutine 通过waitgroup 确保 goroutine执行完成,select+time.After+chanel 终止goroutine等待...
packagemainimport("fmt""log""sync""time")funcmain(){tasks:=make(chanbool,1)gofunc(tchanbool){varwgsync.WaitGroup//需要确保3个协程完成fori:=1;i<=3;i++{wg.Add(1)gofunc(iiint){deferpanicRecover()iferr:=testa(ii);