packagetasksimport("fmt""runtime/debug""golang.org/x/sync/errgroup")// Group is a tasks group, which can at any point be awaited to complete.// Tasks in the group are run in separate go routines.// If a task panics, the panic is recovered with HandleCrit.typeGroupstruct{errGrouperrgroup.GroupHandleCritfunc(errerror)}func(t*Group)Go(fnfunc()error){t.errGroup.Go(func()error{deferfunc(){iferr:=recover();err!=nil{debug.PrintStack()t.HandleCrit(fmt.Errorf("panic: %v",err))}}()returnfn()})}func(t*Group)Wait()error{returnt.errGroup.Wait()}