time.Since
The Go function that returns how much time has passed since a given moment, as a time.Duration.
In more detail
Pair it with time.Now() to measure how long work took. Go measures it with the monotonic clock, so it stays correct even if the wall clock is adjusted while the work runs.
Example
elapsed := time.Since(start)Related terms
- time.Duration — The Go type for a length of time, such as 2*time.Second, stored as a count of nanoseconds.
- wall clock — The computer's real current time, which keeps moving while a program or test runs.
- time package — Go's standard library package for moments, durations, timers and formatting dates, built around the time.Time and time.Duration types.
Taught in
- The time Package — Concurrent Systems Programming with Go