Standard library / time

time.Sleep()

Pause the current goroutine for at least d; nonpositive durations return immediately. It is not synchronization with another goroutine. Expected stdout: 'resumed\n'.

Formal Syntax & Structure

go syntaxgo
func Sleep(d Duration)

Parameters & Attributes

NameTypeDescription
dDurationElapsed duration or interval.

Working Example

Example Snippetgo
package main
import (  "fmt"  "time")
func main() { time.Sleep(0); fmt.Println("resumed") }
Go Reference