我想知道<-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 關注
- 322 瀏覽
添加回答
舉報
0/150
提交
取消