Skip to content

Commit

Permalink
v0.4.x 第一个正式版
Browse files Browse the repository at this point in the history
  • Loading branch information
FishGoddess committed Feb 28, 2023
1 parent ce51301 commit df529d5
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 10 deletions.
6 changes: 6 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## ✒ 历史版本的特性介绍 (Features in old versions)

### v0.4.6

> 此版本发布于 2023-03-01
* 全新设计版本

### v0.4.5-alpha

> 此版本发布于 2023-02-21
Expand Down
4 changes: 2 additions & 2 deletions _icons/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 17 additions & 1 deletion doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,22 @@ Package cachego provides an easy way to use foundation for your caching operatio
9. task:
var (
contextKey = struct{}{}
)
func beforePrint(ctx context.Context) {
fmt.Println("before:", ctx.Value(contextKey))
}
func afterPrint(ctx context.Context) {
fmt.Println("after:", ctx.Value(contextKey))
}
func printContextValue(ctx context.Context) {
fmt.Println("context value:", ctx.Value(contextKey))
}
// Create a context to stop the task.
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
Expand Down Expand Up @@ -451,4 +467,4 @@ Package cachego provides an easy way to use foundation for your caching operatio
package cachego // import "github.com/FishGoddess/cachego"

// Version is the version string representation of cachego.
const Version = "v0.4.5-alpha"
const Version = "v0.4.6"
21 changes: 14 additions & 7 deletions pkg/clock/clock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,26 @@ func BenchmarkClockNow(b *testing.B) {
}
}

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

for i := 0; i < 100; i++ {
testClock = New()
clocks = append(clocks, New())
}

if testClock != clock {
t.Errorf("testClock %p != clock %p", testClock, clock)
for i := 0; i < 100; i++ {
if clocks[i] != clock {
t.Errorf("clocks[i] %p != clock %p", clocks[i], clock)
}
}
}

for i := 0; i < 10; i++ {
// go test -v -cover -run=^TestClock$
func TestClock(t *testing.T) {
testClock := New()

for i := 0; i < 100; i++ {
now := testClock.Now()
t.Log(now)

Expand Down

0 comments on commit df529d5

Please sign in to comment.