4 ms·
Go has time.Duration type as well and works like this: time.Sleep(10 * time.Millisecond)
by neop1x 5y ago
Go has time.Duration type as well and works like this:
time.Sleep(10 * time.Millisecond)
- y3sh 5y agoThe 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