Go Package time: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 10: | Line 10: | ||
* <tt>[https://golang.org/pkg/time/#After time.After]</tt> returns a channel that after the given duration, will send current time on it. This can be used to implement a timeout with <tt>[[Go Channels#select|select]]</tt>. | * <tt>[https://golang.org/pkg/time/#After time.After]</tt> returns a channel that after the given duration, will send current time on it. This can be used to implement a timeout with <tt>[[Go Channels#select|select]]</tt>. | ||
==<tt>time.Sleep()</tt>== | |||
* https://golang.org/pkg/time/#Sleep | |||
Sleep pauses the current goroutine for at least the duration d. A negative or zero duration causes Sleep to return immediately: | |||
<pre> | |||
import "time" | |||
... | |||
time.Sleep(100 * time.Millisecond) | |||
</pre> |
Revision as of 19:17, 20 April 2016
External
Internal
Overview
- time.After returns a channel that after the given duration, will send current time on it. This can be used to implement a timeout with select.
time.Sleep()
Sleep pauses the current goroutine for at least the duration d. A negative or zero duration causes Sleep to return immediately:
import "time" ... time.Sleep(100 * time.Millisecond)