Time
Use time.Time for instants of time
time.Time for instants of time// BAD
func isActive(now, start, stop int) bool {
return start <= now && now < stop
}// GOOD
func isActive(now, start, stop time.Time) bool {
return (start.Before(now) || start.Equal(now)) && now.Before(stop)
}Use time.Duration for periods of time
time.Duration for periods of time// BAD
func poll(delay int) {
for {
// ...
time.Sleep(time.Duration(delay) * time.Millisecond)
}
}
poll(10) // was it seconds or milliseconds?Getting Next Day
Last updated