-
-
Save rekby/a7f3e679e47604b28d22c7736d0ff388 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"github.com/jonboulle/clockwork" | |
"time" | |
) | |
type ZeroClock struct { | |
clock clockwork.Clock | |
} | |
func (z ZeroClock) Sleep(d time.Duration) { | |
if z.clock == nil { | |
time.Sleep(d) | |
} else { | |
z.clock.Sleep(d) | |
} | |
} | |
func (z ZeroClock) Now() time.Time { | |
if z.clock == nil { | |
return time.Now() | |
} | |
return z.clock.Now() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment