github.com/jshiv/can-go@v0.2.1-0.20210224011015-069e90e90bdf/internal/clock/system.go (about) 1 package clock 2 3 import ( 4 "time" 5 ) 6 7 // System returns a Clock implementation that delegate to the time package. 8 func System() Clock { 9 return &systemClock{} 10 } 11 12 type systemClock struct{} 13 14 var _ Clock = &systemClock{} 15 16 func (c systemClock) After(d time.Duration) <-chan time.Time { 17 return time.After(d) 18 } 19 20 func (c systemClock) NewTicker(d time.Duration) Ticker { 21 return &systemTicker{Ticker: *time.NewTicker(d)} 22 } 23 24 func (c systemClock) Now() time.Time { 25 return time.Now() 26 } 27 28 type systemTicker struct { 29 time.Ticker 30 } 31 32 func (t systemTicker) C() <-chan time.Time { 33 return t.Ticker.C 34 }