Sleeping in Go – How to Pause Execution
·
102 words
·
1 minute read
Sleeping, or waiting in Go, is part of the time package. It’s a very simple process, all you need to do is specify the duration to sleep for, which in this case is a number followed by it’s unit, so 2*time.Second
means 2 seconds. This will sleep the current goroutine so other go routines will continue to run.
|
|
And here’s what it looks like: