github.com/jshiv/can-go@v0.2.1-0.20210224011015-069e90e90bdf/internal/clock/clock.go (about) 1 // Package clock provides primitives for mocking time. 2 package clock 3 4 import ( 5 "time" 6 ) 7 8 // Clock provides capabilities from the time standard library package. 9 type Clock interface { 10 // After waits for the duration to elapse and then sends the current time on the returned channel. 11 After(duration time.Duration) <-chan time.Time 12 13 // NewTicker returns a new Ticker. 14 NewTicker(d time.Duration) Ticker 15 16 // Now returns the current local time. 17 Now() time.Time 18 } 19 20 // Ticker wraps the time.Ticker class. 21 type Ticker interface { 22 // C returns the channel on which the ticks are delivered. 23 C() <-chan time.Time 24 25 // Stop the Ticker. 26 Stop() 27 }