3 ms·
Mocking the time module is not very hard, and I recommend writing your own custom mock that fits exactly what you need unless one of the available libraries doe
by llimllib 6y ago
Mocking the time module is not very hard, and I recommend writing your own custom mock that fits exactly what you need unless one of the available libraries does something particularly fancy that you need
- jeffbee 6y agoIt's surprisingly tricky, I wouldn't jump to conclusions. It would depend a great deal on how much fidelity you require to Go's undocumented behavior. For example did you know that the Go runtime (as of today) will not initiate any AfterFunc calls until the goroutine that called AfterFunc yields? Is your application silently reliant on this undocumented synchronization?
- llimllib 6y agoMost people probably won't need to figure that out, and if they did then that would count as the "something fancy" I mentioned. I'm not jumping to conclusions, I have my own mock for time that I wrote in an afternoon which has survived several years on a big golang app