chore: change interface{} to any (#2818)

* chore: change interface{} to any

* chore: update goctl version to 1.5.0

* chore: update goctl deps
This commit is contained in:
Kevin Wan
2023-01-24 16:32:02 +08:00
committed by GitHub
parent 7e0ac77139
commit ae87114282
221 changed files with 1910 additions and 2207 deletions

View File

@@ -62,7 +62,7 @@ func TestCacheNode_DelCache(t *testing.T) {
ticker := timex.NewFakeTicker()
var err error
timingWheel, err = collection.NewTimingWheelWithTicker(
time.Millisecond, timingWheelSlots, func(key, value interface{}) {
time.Millisecond, timingWheelSlots, func(key, value any) {
clean(key, value)
}, ticker)
assert.NoError(t, err)
@@ -146,7 +146,7 @@ func TestCacheNode_Take(t *testing.T) {
cn := NewNode(store, syncx.NewSingleFlight(), NewStat("any"), errTestNotFound,
WithExpiry(time.Second), WithNotFoundExpiry(time.Second))
var str string
err = cn.Take(&str, "any", func(v interface{}) error {
err = cn.Take(&str, "any", func(v any) error {
*v.(*string) = "value"
return nil
})
@@ -167,7 +167,7 @@ func TestCacheNode_TakeBadRedis(t *testing.T) {
cn := NewNode(redis.New(r.Addr()), syncx.NewSingleFlight(), NewStat("any"),
errTestNotFound, WithExpiry(time.Second), WithNotFoundExpiry(time.Second))
var str string
assert.Error(t, cn.Take(&str, "any", func(v interface{}) error {
assert.Error(t, cn.Take(&str, "any", func(v any) error {
*v.(*string) = "value"
return nil
}))
@@ -188,7 +188,7 @@ func TestCacheNode_TakeNotFound(t *testing.T) {
errNotFound: errTestNotFound,
}
var str string
err = cn.Take(&str, "any", func(v interface{}) error {
err = cn.Take(&str, "any", func(v any) error {
return errTestNotFound
})
assert.True(t, cn.IsNotFound(err))
@@ -198,7 +198,7 @@ func TestCacheNode_TakeNotFound(t *testing.T) {
assert.Equal(t, `*`, val)
store.Set("any", "*")
err = cn.Take(&str, "any", func(v interface{}) error {
err = cn.Take(&str, "any", func(v any) error {
return nil
})
assert.True(t, cn.IsNotFound(err))
@@ -206,7 +206,7 @@ func TestCacheNode_TakeNotFound(t *testing.T) {
store.Del("any")
errDummy := errors.New("dummy")
err = cn.Take(&str, "any", func(v interface{}) error {
err = cn.Take(&str, "any", func(v any) error {
return errDummy
})
assert.Equal(t, errDummy, err)
@@ -227,7 +227,7 @@ func TestCacheNode_TakeWithExpire(t *testing.T) {
errNotFound: errors.New("any"),
}
var str string
err = cn.TakeWithExpire(&str, "any", func(v interface{}, expire time.Duration) error {
err = cn.TakeWithExpire(&str, "any", func(v any, expire time.Duration) error {
*v.(*string) = "value"
return nil
})
@@ -277,7 +277,7 @@ func TestCacheValueWithBigInt(t *testing.T) {
)
assert.Nil(t, cn.Set(key, value))
var val interface{}
var val any
assert.Nil(t, cn.Get(key, &val))
assert.Equal(t, strconv.FormatInt(value, 10), fmt.Sprintf("%v", val))
}