摘要: channel不需要通过close释放资源,只要没有goroutine持有channel,相关资源会自动释放。 close可以用来通知channel接收者不会再收到数据 所以即使channel中有数据也可以close而不会导致接收者收不到残留的数据 有些场景需要关闭通道,例如range遍历通道,如不 阅读全文
posted @ 2022-06-25 15:21 许伟强 阅读(264) 评论(0) 推荐(0) 编辑