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 time interface and during test use 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.
I was wondering if there is an alternative way to stub out time.Now()
globally. Maybe making a system call to change the system clock?
Maybe we can 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?