#166·go-cache

cache.go:1079 处的 goroutine 发生泄漏 - `runJanitor`

作者: tigerinus创建于 2023年3月6日更新于 2023年5月17日
go
package main
import (
"testing"
"time"
"GitHub.com/patrickmn/go-cache"
"go.uber.org/goleak"
)
func leaktest(t *testing.T) {
	defer goleak.VerifyNone(t)
	cache.New(5*time.Minute, 10*time.Minute)
}
func main() {
	testSuite := []testing.InternalTest{{Name: "leaktest", F: leaktest}}
	testing.Main(func(a, b string) (bool, error) { return a == b, nil }, testSuite, nil, nil)
}
运行上述代码(https://go.dev/play/p/PxN4Q4-F2rG)

内容来源: patrickmn/go-cache