3 ms·
I've done this too, because passing a mockable time everywhere would just clutter the code, and this is an instance where a package-level global isn't going to
by physicles 6y ago
I've done this too, because passing a mockable time everywhere would just clutter the code, and this is an instance where a package-level global isn't going to bite you in the ass -- in prod anyway (in tests you might get your wires crossed, but seen another way, a global ensures all parts of your program think it's the same time).
Difference in mine is that dates.SetNowSource returns a reset function that you can defer, like with context.WithCancel().