File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change @@ -393,6 +393,22 @@ Package cachego provides an easy way to use foundation for your caching operatio
393393
3943949. 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
451467package 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 "
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments