Source File
time_helper.go
Belonging Package
github.com/go-co-op/gocron
package gocron
import
var _ TimeWrapper = (*trueTime)(nil)
// TimeWrapper is an interface that wraps the Now, Sleep, and Unix methods of the time package.
// This allows the library and users to mock the time package for testing.
type TimeWrapper interface {
Now(*time.Location) time.Time
Unix(int64, int64) time.Time
Sleep(time.Duration)
}
type trueTime struct{}
func ( *trueTime) ( *time.Location) time.Time {
return time.Now().In()
}
func ( *trueTime) ( int64, int64) time.Time {
return time.Unix(, )
}
func ( *trueTime) ( time.Duration) {
time.Sleep()
}
// afterFunc proxies the time.AfterFunc function.
// This allows it to be mocked for testing.
func afterFunc( time.Duration, func()) *time.Timer {
return time.AfterFunc(, )
}
![]() |
The pages are generated with Golds v0.6.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |