我想知道<-Go 中函数的通道返回类型是什么意思。实际上,类型 T 的通道是使用 编写chan T和创建的make(chan T, N),那么“ <-”在 的返回类型中是什么意思time.After?go doc time.Afterpackage time // import "time"func After(d Duration) <-chan Time After waits for the duration to elapse and then sends the current time on the returned channel. It is equivalent to NewTimer(d).C. The underlying Timer is not recovered by the garbage collector until the timer fires. If efficiency is a concern, use NewTimer instead and call Timer.Stop if the timer is no longer needed.奖金:我如何从中go doc看出time.After是异步的并且在持续时间过去之前不会阻塞?
1 回答
慕的地10843
TA贡献1785条经验 获得超8个赞
返回时间值的只读通道的方法<-chan time。After
Achan time是一个读写通道。
奖金:
你说的对。文档不够清楚。您必须从签名中猜测它。
您可能会建议对所做的事情进行更好且不那么模棱两可的描述After。Go 是一个开源项目,这将是一个贡献的机会。
- 1 回答
- 0 关注
- 355 浏览
添加回答
举报
0/150
提交
取消
