clock
clock copied to clipboard
Minimise bugs by removing top level implementation?
Great package, but I'm confused by the presence of a top level set of functions, e.g. clock.Now().
This makes it easier to do silly bugs like:
type someStruct {
clock clock.Clock
}
func (s someStruct) someTimeCriticalFunc() {
currentTime := clock.Now() // should be s.clock.Now()
}
Ignoring backwards compatibility for a second, what is the benefit of having the clock.Now() function? Anyone who specifically wants the real time can just call clock.New().Now(). Or even just call time.Now(), since they obviously know they need the correct time at that point in their code.
I thought the whole point of this library would be to force users to access all time information through an interface.