time.Duration

The Go type for a length of time, such as 2*time.Second, stored as a count of nanoseconds.

In more detail

Write durations with the unit constants, as in 30*time.Second, never as bare numbers. A Duration prints readably, like 2s or 1.5ms, and flag.Duration parses the same form from the command line.

Example

wait := flag.Duration("timeout", 2*time.Second, "deadline per attempt")

Related terms

Taught in

References