Skip to content

Instantly share code, notes, and snippets.

@rekby
Last active April 1, 2023 15:50
Show Gist options
  • Save rekby/a7f3e679e47604b28d22c7736d0ff388 to your computer and use it in GitHub Desktop.
Save rekby/a7f3e679e47604b28d22c7736d0ff388 to your computer and use it in GitHub Desktop.
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