This question already has an answer here:
Was looking at the source code go source code, below is a snippet from sleep.go (package time):
package 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
How is it possible that func Sleep(d Duration) doesn't have any implementation? Where can I find the exact implementation of Sleep function?
Edit: The answer can be found in the 2 links provided by @DaveC. However please read the comments below to see the explanation about why empty function can't be replaced with Go even after bootstrapping Go (1.5)
</div>
Considering what Sleep()
does (it deschedules a golang thread for a given amount of time), you can't express that it in go, so it's probably implemented as some kind of compiler instrinsic.
Whoa, lots of downvotes here. It looks like Sleep
is in fact implemented in assembly.