Part of our code is time-sensitive, and we need to able to reserve something and then release it in 30-60 seconds, etc., which we can just do a time.Sleep(60 * time.Second)
.
I have just implemented the time interface, and during the test I used a stubbed implementation of the time interface, similar to this golang-nuts discussion.
However, time.Now()
is called in multiple sites which means we need to pass a variable around to keep track of how much time we have actually slept.
Is there an alternative way to stub out time.Now()
globally? Maybe making a system call to change the system clock?
Can we maybe write our own time package which basically wraps around the time package but allows us to change it?
Our current implementation works well. I am a Go beginner, and I am curious to see if anyone has other ideas.