【问题标题】:Where is time.Sleep function declaration? [duplicate]time.Sleep 函数声明在哪里? [复制]
【发布时间】:2017-12-20 17:08:57
【问题描述】:

这里是 Go 核心库的 time 包中文件 sleep.go 的第一行:

// Sleep pauses the current goroutine for at least the duration d.
// A negative or zero duration causes Sleep to return immediately.

func Sleep(d Duration)

// runtimeNano returns the current value of the runtime clock in nanoseconds.
func runtimeNano() int64

为什么这里没有声明函数time.Sleep?它在哪里?

【问题讨论】:

标签: go


【解决方案1】:

它在runtime/time.go

有关go:linkname 的详细信息,请参阅compiler directives

【讨论】: