An open API service providing package, version and dependency metadata of many open source software ecosystems and registries.

github.com/tilinna/clock

Package clock implements a library for mocking time. Include a Clock variable on your application and initialize it with a Realtime() by default. Then use the Clock for all time-related API calls. So instead of time.NewTimer(), say myClock.NewTimer(). On a test setup, override or inject the variable with a Mock instance and use it to control how the time behaves during each test phase. To mock context.WithTimeout and context.WithDeadline, use the included Context, TimeoutContext and DeadlineContext methods. The Context method is also useful in cases where you need to pass a Clock via an 'func(ctx Context, ..)' API you can't change yourself. The FromContext method will then return the associated Clock instance. Alternatively, use the context'ed methods like Sleep(ctx) directly. All methods are safe for concurrent use.

Ecosystem
proxy.golang.org
Latest Release
v1.1.0
about 5 years ago
Versions
4
Dependent Packages
184
Dependent Repos
766
Links
Registry proxy.golang.org
Source Repository
Docs Documentation
JSON API View JSON
CodeMeta codemeta.json
Package Details
PURL pkg:golang/github.com/tilinna/clock
spec
License MIT
Namespace github.com/tilinna
First Release almost 8 years ago
Last Synced 1 day ago
Repository
Stars 15 on GitHub
Forks 4 on GitHub
Docker Dependents 187
Docker Downloads 788,457,501
Rankings on proxy.golang.org
Overall Top 4.0%
Dependent packages Top 0.3%
Dependent repos Top 0.3%
Forks Top 9.8%
Docker downloads Top 0.2%