Skip to content

Commit df529d5

Browse files
committed
v0.4.x 第一个正式版
1 parent ce51301 commit df529d5

4 files changed

Lines changed: 39 additions & 10 deletions

File tree

HISTORY.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
## ✒ 历史版本的特性介绍 (Features in old versions)
22

3+
### v0.4.6
4+
5+
> 此版本发布于 2023-03-01
6+
7+
* 全新设计版本
8+
39
### v0.4.5-alpha
410

511
> 此版本发布于 2023-02-21

_icons/coverage.svg

Lines changed: 2 additions & 2 deletions
Loading

doc.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,22 @@ Package cachego provides an easy way to use foundation for your caching operatio
393393
394394
9. task:
395395
396+
var (
397+
contextKey = struct{}{}
398+
)
399+
400+
func beforePrint(ctx context.Context) {
401+
fmt.Println("before:", ctx.Value(contextKey))
402+
}
403+
404+
func afterPrint(ctx context.Context) {
405+
fmt.Println("after:", ctx.Value(contextKey))
406+
}
407+
408+
func printContextValue(ctx context.Context) {
409+
fmt.Println("context value:", ctx.Value(contextKey))
410+
}
411+
396412
// Create a context to stop the task.
397413
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
398414
defer cancel()
@@ -451,4 +467,4 @@ Package cachego provides an easy way to use foundation for your caching operatio
451467
package cachego // import "github.com/FishGoddess/cachego"
452468

453469
// Version is the version string representation of cachego.
454-
const Version = "v0.4.5-alpha"
470+
const Version = "v0.4.6"

pkg/clock/clock_test.go

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,26 @@ func BenchmarkClockNow(b *testing.B) {
4343
}
4444
}
4545

46-
// go test -v -cover -run=^TestClock$
47-
func TestClock(t *testing.T) {
48-
testClock := New()
46+
// go test -v -cover -run=^TestNew$
47+
func TestNew(t *testing.T) {
48+
var clocks []*Clock
4949

5050
for i := 0; i < 100; i++ {
51-
testClock = New()
51+
clocks = append(clocks, New())
52+
}
5253

53-
if testClock != clock {
54-
t.Errorf("testClock %p != clock %p", testClock, clock)
54+
for i := 0; i < 100; i++ {
55+
if clocks[i] != clock {
56+
t.Errorf("clocks[i] %p != clock %p", clocks[i], clock)
5557
}
5658
}
59+
}
5760

58-
for i := 0; i < 10; i++ {
61+
// go test -v -cover -run=^TestClock$
62+
func TestClock(t *testing.T) {
63+
testClock := New()
64+
65+
for i := 0; i < 100; i++ {
5966
now := testClock.Now()
6067
t.Log(now)
6168

0 commit comments

Comments
 (0)