don't set a timer when the deadline is the zero value

This commit is contained in:
Marten Seemann
2018-12-16 21:04:39 +06:30
parent 072b84870c
commit 516b427d46
2 changed files with 9 additions and 1 deletions

View File

@@ -34,7 +34,9 @@ func (t *Timer) Reset(deadline time.Time) {
if !t.t.Stop() && !t.read {
<-t.t.C
}
t.t.Reset(time.Until(deadline))
if !deadline.IsZero() {
t.t.Reset(time.Until(deadline))
}
t.read = false
t.deadline = deadline