Skip to content

Commit 978d781

Browse files
committed
[refactoring] Remove useless returning of error
1 parent ff66372 commit 978d781

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

pkg/timer/timer.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,25 +91,24 @@ func (t *Timer) Stop() error {
9191
}
9292

9393
// WaitTill waits until the internal timer duration is reached.
94-
func (t *Timer) WaitTill(duration time.Duration) error {
94+
func (t *Timer) WaitTill(duration time.Duration) {
9595
if !t.running {
9696
select {
9797
case t.continueChan <- struct{}{}:
9898
case <-time.After(1 * time.Second):
99-
return nil
99+
return
100100
}
101101
}
102102
sleepTime := duration - t.Elapsed()
103103
if sleepTime > 0 {
104104
t.SleepConsumer(sleepTime)
105105
}
106-
return nil
106+
return
107107
}
108108

109109
// WaitTillNextFullSecond waits until the internal timer has reached the next full second
110-
func (t *Timer) WaitTillNextFullSecond() error {
110+
func (t *Timer) WaitTillNextFullSecond() {
111111
elapsed := t.Elapsed()
112112
nextDuration := elapsed.Truncate(time.Second) + time.Second
113113
t.WaitTill(nextDuration)
114-
return nil
115114
}

pkg/timer/timer_test.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,14 @@ func TestTimerWaitTill(t *testing.T) {
5656
t.Error(err)
5757
}
5858
*curTime = curTime.Add(2 * time.Second)
59-
err = timer.WaitTill(5 * time.Second)
60-
if err != nil {
61-
t.Error(err)
62-
}
59+
timer.WaitTill(5 * time.Second)
6360
if *sleepDuration != 3*time.Second {
6461
t.Errorf("Expected a sleep duration of 3s, but was %v", *sleepDuration)
6562
}
6663

6764
*sleepDuration = 0
6865
*curTime = curTime.Add(100 * time.Millisecond)
69-
err = timer.WaitTillNextFullSecond()
70-
if err != nil {
71-
t.Error(err)
72-
}
66+
timer.WaitTillNextFullSecond()
7367
if *sleepDuration != 900*time.Millisecond {
7468
t.Errorf("Expected a sleep duration of 900ms, but was %v", *sleepDuration)
7569
}

0 commit comments

Comments
 (0)