1. 首页
  2. 主题
  3. Go语言

这个函数返回值能配上吗?

freboat · · 2261 次点击
``` // Waits for a random time between two durations and sends the current time on // the returned channel. func afterBetween(min time.Duration, max time.Duration) <-chan time.Time { rand := rand.New(rand.NewSource(time.Now().UnixNano())) d, delta := min, (max - min) if delta > 0 { d += time.Duration(rand.Int63n(int64(delta))) } return time.After(d) ///After是标准库里的, 返回的是bool } ``` 上面的time.After(d)和 <-chan time.Time 怎么匹配的?
标准库 `time.After` 返回的是 `&lt;-chan Time`
#1
更多评论
嗯, 你是对的, 我看到的是 time.t.After(d)版本, 被误导了 golang的packege和object区分不明显, 只能看源代码才能区分开
#2

用户登录

没有账号?注册

今日阅读排行

    加载中

一周阅读排行

    加载中