Skip to content

Commit 449bce5

Browse files
committed
[refactoring] More golint fixes
1 parent 5b50f6d commit 449bce5

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

pkg/timer/timer.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ import (
99
// This is usually the system time, but can be something else for unit tests.
1010
type TimeProvider func() time.Time
1111

12-
// The default system time provider
12+
// SysTimeProvider is the default system time provider
1313
var SysTimeProvider = func() time.Time { return time.Now() }
1414

15-
// A SleepConsumer sleeps the given amount of time.
15+
// SleepConsumer sleeps the given amount of time.
1616
// This is usually the time.Sleep method, but can be something else for unit tests.
1717
type SleepConsumer func(time.Duration)
1818

19-
// The default system sleep consumer
19+
// SysSleepConsumer is the default system sleep consumer
2020
var SysSleepConsumer = func(d time.Duration) { time.Sleep(d) }
2121

2222
// A Timer can be started and stopped. It will start at zero and count up, while running.
@@ -31,7 +31,7 @@ type Timer struct {
3131
continueChan chan struct{}
3232
}
3333

34-
// Create a new stopped timer based on system time
34+
// NewTimer creates a new stopped timer based on system time
3535
func NewTimer() Timer {
3636
return Timer{
3737
time.Now(),
@@ -43,19 +43,20 @@ func NewTimer() Timer {
4343
make(chan struct{})}
4444
}
4545

46-
// Is timer currently running?
46+
// Running returns if timer is currently running
4747
func (t *Timer) Running() bool {
4848
return t.running
4949
}
5050

51-
// Return the elapsed time of this timer
51+
// Elapsed returns the elapsed time of this timer
5252
func (t *Timer) Elapsed() time.Duration {
5353
if t.running {
5454
return t.offset + t.TimeProvider().Sub(t.start)
5555
}
5656
return t.offset
5757
}
5858

59+
// Delta returns the time since last call to Delta
5960
func (t *Timer) Delta() time.Duration {
6061
elapsed := t.Elapsed()
6162
delta := elapsed - t.deltaOffset
@@ -89,7 +90,7 @@ func (t *Timer) Stop() error {
8990
return nil
9091
}
9192

92-
// Wait until the internal timer duration is reached.
93+
// WaitTill waits until the internal timer duration is reached.
9394
func (t *Timer) WaitTill(duration time.Duration) error {
9495
if !t.running {
9596
select {
@@ -105,7 +106,7 @@ func (t *Timer) WaitTill(duration time.Duration) error {
105106
return nil
106107
}
107108

108-
// Wait until the internal timer has reached the next full second
109+
// WaitTillNextFullSecond waits until the internal timer has reached the next full second
109110
func (t *Timer) WaitTillNextFullSecond() error {
110111
elapsed := t.Elapsed()
111112
nextDuration := elapsed.Truncate(time.Second) + time.Second

0 commit comments

Comments
 (0)