4 ms·
The Go compiler is also happy with time.Sleep(1000), which the new "expert full stack" dev just PR'd. To me Durations are a zero sum gain, because in this case
by y3sh 5y ago
The Go compiler is also happy with time.Sleep(1000), which the new "expert full stack" dev just PR'd.
To me Durations are a zero sum gain, because in this case they hide relevant detail (int64 nanoseconds) without enforcing usage. Compare it against what Golang could easily provide -- time.SleepMilli(100), which is 40% less characters for my aging eyes to parse than time.Sleep(100 * time.Millisecond).
After all, in the very same package we have a unit in the name:
t := time.Time{}
t.UnixMilli() // 1647952024456