Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
What version of Go are you using (
It seems reasonable to be able to change the duration on a ticker.
The second seems defensible to me and useful in code that is doing something like:
In general, if the Reset is happening separate from the channel receive, you'd want to do t.Stop, then synchronize with the receiver so it knows to expect a new duration, then t.Reset. But the pattern above does not need that because the receiver and the Reset caller are the same, and that seems likely to be common.
So I would lean toward option 2. Thoughts?
This way developers can control their own startup time,later added api Reset,using like this:
But this does have a situation where stopTimer returns an error,do you have a better solution?