jonboulle / clockwork

a fake clock for golang
Apache License 2.0
625 stars 57 forks source link

Make NewTicker panic if d<=0, like time.NewTicker. #64

Closed DPJacques closed 11 months ago

DPJacques commented 1 year ago

This more closely follows the standard library function behavior.

It is directly copied from the standard library: https://cs.opensource.google/go/go/+/refs/tags/go1.20.3:src/time/tick.go;l=23-25

Although panicking is generally bad, it is preferable to mimic the standard library so users see the same behavior between clockwork and the golang standard library.

Without this, some tests can pass with a no op where a real time.Ticker implementation would crash.

DPJacques commented 1 year ago

Hey @sagikazarmark, Wanted to send a friendly ping on this. Would you be willing to share your thoughts on this?

This had caught me once a few years ago, but I was lazy at the time and didn't upstream it.