为了账号安全,请及时绑定邮箱和手机立即绑定

Go中函数的通道返回类型中的`<-`是什么意思?

Go中函数的通道返回类型中的`<-`是什么意思?

Go
呼如林 2022-04-26 10:42:14
我想知道<-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 timeAfter

Achan time是一个读写通道。

奖金:

你说的对。文档不够清楚。您必须从签名中猜测它。

您可能会建议对所做的事情进行更好且不那么模棱两可的描述After。Go 是一个开源项目,这将是一个贡献的机会。


查看完整回答
反对 回复 2022-04-26
  • 1 回答
  • 0 关注
  • 355 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号