time.Sleep函数声明在哪里? [重复]

问题描述 投票:0回答:1

这个问题在这里已有答案:

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

// 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个回答
4
投票

它在runtime/time.go

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

© www.soinside.com 2019 - 2024. All rights reserved.