Go Package time: Difference between revisions
Jump to navigation
Jump to search
(→Now()) |
|||
Line 21: | Line 21: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Other available time units: <code>time.Milliseconds</code>. | Other available time units: <code>time.Milliseconds</code>. | ||
=<tt>Now()</tt>= | =<tt>Now()</tt>= |
Revision as of 21:29, 2 October 2023
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 withselect
.
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"
...
secs := 10
time.Sleep(time.Duration(secs) * time.Second)
Other available time units: time.Milliseconds
.
Now()
Return the current local time as an instance of a Time
struct.
Time
sec()
Return seconds since Jan 1 year 1.