Go uses monotonic clocks automatically for duration calculations via time.Now() and time.Since() to ensure accuracy despite system clock changes.
Use time.Now() for wall-clock time and time.Since() for durations; Go's standard library does not expose a raw monotonic clock counter directly. The time package automatically uses the system's monotonic clock for duration calculations to prevent errors from system clock adjustments.
start := time.Now()
// ... do work ...
duration := time.Since(start)
fmt.Println(duration)
A monotonic clock is a timer that only moves forward and never jumps backward, even if someone changes your computer's system time. You use it to measure how long something takes, like timing a race, because it won't get confused if the clock is reset. In Go, you don't need to find a special tool; the standard time package handles this automatically for you whenever you measure a duration.