我想知道<-Go 中函數(shù)的通道返回類型意味著什么。事實上,類型 T 的通道被寫為chan T并使用 來創(chuàng)建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是異步的并且在持續(xù)時間過去之前不會阻塞?
1 回答

忽然笑
TA貢獻1806條經(jīng)驗 獲得超5個贊
返回時間值的只讀<-chan time
通道的方法。After
Achan time
是讀寫通道。
獎金:
你是對的。文檔不夠清晰。你必須從簽名中猜測出來。
你也許可以建議一個更好、更明確的描述After
。Go 是一個開源項目,這將是一個做出貢獻的機會。
- 1 回答
- 0 關注
- 128 瀏覽
添加回答
舉報
0/150
提交
取消