不用管理 grouting 和 channel 了。 以下为转发 golangtc.com 原文:
刚刚写了个包,觉得值得出来分享下:
文档: https://github.com/sunfmin/fanout
用来简化并发程序(goroutine, channel)的编写,这个包直接改写自Go Concurrency Patterns: Pipelines博客的最后一个样例程序。
平时写带goroutine和channel的程序,总是时不时的爆”fatal error: all goroutines are asleep - deadlock!“,检查起来又很难找原因。
例子程序 - 用60个goroutine一起跑whois来查看域名是不是还在:
|
|
一图来说明: