相关疑难解决方法(0)

没有身体的功能是什么意思?

我正在阅读包的代码,time然后我想知道它是如何func After(d Duration) <-chan Time工作的.

我发现代码如下:

func After(d Duration) <-chan Time {
    return NewTimer(d).C
}

func NewTimer(d Duration) *Timer {
    c := make(chan Time, 1)
    t := &Timer{
        C: c,
        r: runtimeTimer{
            when: nano() + int64(d),
            f:    sendTime,
            arg:  c,
        },
    }
    startTimer(&t.r)
    return t
}
Run Code Online (Sandbox Code Playgroud)

所以我找到了startTimer- 函数startTimer没有函数体这么奇怪.

func startTimer(*runtimeTimer)
Run Code Online (Sandbox Code Playgroud)

我想知道:

  1. 真正的代码在哪里? startTimer
  2. 为什么这里可以存在"抽象方法"
  3. 为什么Go的作者这样写了

谢谢!

go abstract-methods

25
推荐指数
1
解决办法
2806
查看次数

标签 统计

abstract-methods ×1

go ×1