type Engine struct { queue chan interface{} } // 推送请求到队列 func (e *Engine) Push(req interface{}) { e.queue <- req } // 开启服务协程 func (e *Engine) Serve() { go func() { for { req := <-e.queue // do some thing _ = req } }() }原文链接:https://www.f2er.com/go/189417.html