should use time.Since instead of time.Now().Sub
74}
75
76func timer(t0 time.Time) time.Duration {
77 dur := time.Now().Sub(t0)78 return dur
79}
80
Description
The time.Since(t)
helper has the same effect as using time.Now().Sub(t)
.
time.Since(t)
returns the time elapsed since t
. It is shorthand for
time.Now().Sub(t)
.
Bad practice
time.Now().Sub(x)
Recommended
time.Since(x)