如何优雅地关闭Go channel

天唯 ·
这篇文章充斥的Nonsense,既然只能是sender close chan,那么判断是否关闭只需要在接收端判断。尤其isClose方法是极其可笑的, d ,ok <- chan,第二个ok参数本来就在close时候会返回false,
#4
更多评论
咨询一个问题,go语言实战上面的例子,先关闭channel,然后range,这可行么?谢谢 // Close the channel before we drain the channel of its // resources. If we don't do this, we will have a deadlock. close(p.resources) // Close the resources for r := range p.resources { r.Close() }
#1
咨询一个问题,go语言实战上面的例子,先关闭channel,然后range,这可行么?谢谢 ```go { // Close the channel before we drain the channel of its // resources. If we don't do this, we will have a deadlock. close(p.resources) // Close the resources for r := range p.resources { r.Close() } } ```
#2