Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8caaed8

Browse files
committed
chore: add clock pkg for testing time
1 parenta51076a commit8caaed8

File tree

6 files changed

+632
-45
lines changed

6 files changed

+632
-45
lines changed

‎clock/clock.go‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Package clock is a library for testing time related code. It exports an interface Clock that
2+
// mimics the standard library time package functions. In production, an implementation that calls
3+
// thru to the standard libary is used. In testing, a Mock clock is used to precisely control and
4+
// intercept time functions.
5+
package clock
6+
7+
import (
8+
"context"
9+
"time"
10+
)
11+
12+
typeClockinterface {
13+
// NewContextTicker is a convenience function that calls f on the interval d until either the
14+
// given context expires or f returns an error. Callers may call Wait() on the returned Waiter
15+
// to wait until this happens and obtain the errror.
16+
NewContextTicker(ctx context.Context,d time.Duration,ffunc()error,tags...string)Waiter
17+
NewTimer(d time.Duration,tags...string)*Timer
18+
}
19+
20+
// Waiter can be waited on for an error.
21+
typeWaiterinterface {
22+
Wait(tags...string)error
23+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp