企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
[TOC] ## 模块 ``` package wait import ( "sync" "time" ) type Wait struct { wg sync.WaitGroup } func (w *Wait)Add(delta int) { w.wg.Add(delta) } func (w *Wait)Done() { w.wg.Done() } func (w *Wait)Wait() { w.wg.Wait() } // return isTimeout func (w *Wait)WaitWithTimeout(timeout time.Duration)bool { c := make(chan bool) go func() { defer close(c) w.wg.Wait() c <- true }() select { case <-c: return false // completed normally case <-time.After(timeout): return true // timed out } } ```