diff --git a/core/collection/cache.go b/core/collection/cache.go index 7d3263a0..ace21ece 100644 --- a/core/collection/cache.go +++ b/core/collection/cache.go @@ -30,7 +30,7 @@ type ( Cache struct { name string lock sync.Mutex - data map[string]interface{} + data map[string]any expire time.Duration timingWheel *TimingWheel lruCache lru @@ -43,7 +43,7 @@ type ( // NewCache returns a Cache with given expire. func NewCache(expire time.Duration, opts ...CacheOption) (*Cache, error) { cache := &Cache{ - data: make(map[string]interface{}), + data: make(map[string]any), expire: expire, lruCache: emptyLruCache, barrier: syncx.NewSingleFlight(), @@ -59,7 +59,7 @@ func NewCache(expire time.Duration, opts ...CacheOption) (*Cache, error) { } cache.stats = newCacheStat(cache.name, cache.size) - timingWheel, err := NewTimingWheel(time.Second, slots, func(k, v interface{}) { + timingWheel, err := NewTimingWheel(time.Second, slots, func(k, v any) { key, ok := k.(string) if !ok { return @@ -85,7 +85,7 @@ func (c *Cache) Del(key string) { } // Get returns the item with the given key from c. -func (c *Cache) Get(key string) (interface{}, bool) { +func (c *Cache) Get(key string) (any, bool) { value, ok := c.doGet(key) if ok { c.stats.IncrementHit() @@ -97,12 +97,12 @@ func (c *Cache) Get(key string) (interface{}, bool) { } // Set sets value into c with key. -func (c *Cache) Set(key string, value interface{}) { +func (c *Cache) Set(key string, value any) { c.SetWithExpire(key, value, c.expire) } // SetWithExpire sets value into c with key and expire with the given value. -func (c *Cache) SetWithExpire(key string, value interface{}, expire time.Duration) { +func (c *Cache) SetWithExpire(key string, value any, expire time.Duration) { c.lock.Lock() _, ok := c.data[key] c.data[key] = value @@ -120,14 +120,14 @@ func (c *Cache) SetWithExpire(key string, value interface{}, expire time.Duratio // Take returns the item with the given key. // If the item is in c, return it directly. // If not, use fetch method to get the item, set into c and return it. -func (c *Cache) Take(key string, fetch func() (interface{}, error)) (interface{}, error) { +func (c *Cache) Take(key string, fetch func() (any, error)) (any, error) { if val, ok := c.doGet(key); ok { c.stats.IncrementHit() return val, nil } var fresh bool - val, err := c.barrier.Do(key, func() (interface{}, error) { + val, err := c.barrier.Do(key, func() (any, error) { // because O(1) on map search in memory, and fetch is an IO query // so we do double check, cache might be taken by another call if val, ok := c.doGet(key); ok { @@ -157,7 +157,7 @@ func (c *Cache) Take(key string, fetch func() (interface{}, error)) (interface{} return val, nil } -func (c *Cache) doGet(key string) (interface{}, bool) { +func (c *Cache) doGet(key string) (any, bool) { c.lock.Lock() defer c.lock.Unlock() diff --git a/core/collection/cache_test.go b/core/collection/cache_test.go index 7fc0f465..5b8ec260 100644 --- a/core/collection/cache_test.go +++ b/core/collection/cache_test.go @@ -52,7 +52,7 @@ func TestCacheTake(t *testing.T) { for i := 0; i < 100; i++ { wg.Add(1) go func() { - cache.Take("first", func() (interface{}, error) { + cache.Take("first", func() (any, error) { atomic.AddInt32(&count, 1) time.Sleep(time.Millisecond * 100) return "first element", nil @@ -76,7 +76,7 @@ func TestCacheTakeExists(t *testing.T) { wg.Add(1) go func() { cache.Set("first", "first element") - cache.Take("first", func() (interface{}, error) { + cache.Take("first", func() (any, error) { atomic.AddInt32(&count, 1) time.Sleep(time.Millisecond * 100) return "first element", nil @@ -99,7 +99,7 @@ func TestCacheTakeError(t *testing.T) { for i := 0; i < 100; i++ { wg.Add(1) go func() { - _, err := cache.Take("first", func() (interface{}, error) { + _, err := cache.Take("first", func() (any, error) { atomic.AddInt32(&count, 1) time.Sleep(time.Millisecond * 100) return "", errDummy diff --git a/core/collection/fifo.go b/core/collection/fifo.go index 33ad7be7..c310af10 100644 --- a/core/collection/fifo.go +++ b/core/collection/fifo.go @@ -5,7 +5,7 @@ import "sync" // A Queue is a FIFO queue. type Queue struct { lock sync.Mutex - elements []interface{} + elements []any size int head int tail int @@ -15,7 +15,7 @@ type Queue struct { // NewQueue returns a Queue object. func NewQueue(size int) *Queue { return &Queue{ - elements: make([]interface{}, size), + elements: make([]any, size), size: size, } } @@ -30,12 +30,12 @@ func (q *Queue) Empty() bool { } // Put puts element into q at the last position. -func (q *Queue) Put(element interface{}) { +func (q *Queue) Put(element any) { q.lock.Lock() defer q.lock.Unlock() if q.head == q.tail && q.count > 0 { - nodes := make([]interface{}, len(q.elements)+q.size) + nodes := make([]any, len(q.elements)+q.size) copy(nodes, q.elements[q.head:]) copy(nodes[len(q.elements)-q.head:], q.elements[:q.head]) q.head = 0 @@ -49,7 +49,7 @@ func (q *Queue) Put(element interface{}) { } // Take takes the first element out of q if not empty. -func (q *Queue) Take() (interface{}, bool) { +func (q *Queue) Take() (any, bool) { q.lock.Lock() defer q.lock.Unlock() diff --git a/core/collection/ring.go b/core/collection/ring.go index bdde1858..8218d60d 100644 --- a/core/collection/ring.go +++ b/core/collection/ring.go @@ -4,7 +4,7 @@ import "sync" // A Ring can be used as fixed size ring. type Ring struct { - elements []interface{} + elements []any index int lock sync.RWMutex } @@ -16,12 +16,12 @@ func NewRing(n int) *Ring { } return &Ring{ - elements: make([]interface{}, n), + elements: make([]any, n), } } // Add adds v into r. -func (r *Ring) Add(v interface{}) { +func (r *Ring) Add(v any) { r.lock.Lock() defer r.lock.Unlock() @@ -30,7 +30,7 @@ func (r *Ring) Add(v interface{}) { } // Take takes all items from r. -func (r *Ring) Take() []interface{} { +func (r *Ring) Take() []any { r.lock.RLock() defer r.lock.RUnlock() @@ -43,7 +43,7 @@ func (r *Ring) Take() []interface{} { size = r.index } - elements := make([]interface{}, size) + elements := make([]any, size) for i := 0; i < size; i++ { elements[i] = r.elements[(start+i)%len(r.elements)] } diff --git a/core/collection/ring_test.go b/core/collection/ring_test.go index 70a126bb..961659e3 100644 --- a/core/collection/ring_test.go +++ b/core/collection/ring_test.go @@ -19,7 +19,7 @@ func TestRingLess(t *testing.T) { ring.Add(i) } elements := ring.Take() - assert.ElementsMatch(t, []interface{}{0, 1, 2}, elements) + assert.ElementsMatch(t, []any{0, 1, 2}, elements) } func TestRingMore(t *testing.T) { @@ -28,7 +28,7 @@ func TestRingMore(t *testing.T) { ring.Add(i) } elements := ring.Take() - assert.ElementsMatch(t, []interface{}{6, 7, 8, 9, 10}, elements) + assert.ElementsMatch(t, []any{6, 7, 8, 9, 10}, elements) } func TestRingAdd(t *testing.T) { diff --git a/core/collection/safemap.go b/core/collection/safemap.go index 4856f147..6ab328a0 100644 --- a/core/collection/safemap.go +++ b/core/collection/safemap.go @@ -14,20 +14,20 @@ type SafeMap struct { lock sync.RWMutex deletionOld int deletionNew int - dirtyOld map[interface{}]interface{} - dirtyNew map[interface{}]interface{} + dirtyOld map[any]any + dirtyNew map[any]any } // NewSafeMap returns a SafeMap. func NewSafeMap() *SafeMap { return &SafeMap{ - dirtyOld: make(map[interface{}]interface{}), - dirtyNew: make(map[interface{}]interface{}), + dirtyOld: make(map[any]any), + dirtyNew: make(map[any]any), } } // Del deletes the value with the given key from m. -func (m *SafeMap) Del(key interface{}) { +func (m *SafeMap) Del(key any) { m.lock.Lock() if _, ok := m.dirtyOld[key]; ok { delete(m.dirtyOld, key) @@ -42,21 +42,21 @@ func (m *SafeMap) Del(key interface{}) { } m.dirtyOld = m.dirtyNew m.deletionOld = m.deletionNew - m.dirtyNew = make(map[interface{}]interface{}) + m.dirtyNew = make(map[any]any) m.deletionNew = 0 } if m.deletionNew >= maxDeletion && len(m.dirtyNew) < copyThreshold { for k, v := range m.dirtyNew { m.dirtyOld[k] = v } - m.dirtyNew = make(map[interface{}]interface{}) + m.dirtyNew = make(map[any]any) m.deletionNew = 0 } m.lock.Unlock() } // Get gets the value with the given key from m. -func (m *SafeMap) Get(key interface{}) (interface{}, bool) { +func (m *SafeMap) Get(key any) (any, bool) { m.lock.RLock() defer m.lock.RUnlock() @@ -70,7 +70,7 @@ func (m *SafeMap) Get(key interface{}) (interface{}, bool) { // Range calls f sequentially for each key and value present in the map. // If f returns false, range stops the iteration. -func (m *SafeMap) Range(f func(key, val interface{}) bool) { +func (m *SafeMap) Range(f func(key, val any) bool) { m.lock.RLock() defer m.lock.RUnlock() @@ -87,7 +87,7 @@ func (m *SafeMap) Range(f func(key, val interface{}) bool) { } // Set sets the value into m with the given key. -func (m *SafeMap) Set(key, value interface{}) { +func (m *SafeMap) Set(key, value any) { m.lock.Lock() if m.deletionOld <= maxDeletion { if _, ok := m.dirtyNew[key]; ok { diff --git a/core/collection/safemap_test.go b/core/collection/safemap_test.go index 24f42152..26c734ee 100644 --- a/core/collection/safemap_test.go +++ b/core/collection/safemap_test.go @@ -138,7 +138,7 @@ func TestSafeMap_Range(t *testing.T) { } var count int32 - m.Range(func(k, v interface{}) bool { + m.Range(func(k, v any) bool { atomic.AddInt32(&count, 1) newMap.Set(k, v) return true diff --git a/core/collection/set.go b/core/collection/set.go index e067ae23..774fa26e 100644 --- a/core/collection/set.go +++ b/core/collection/set.go @@ -17,14 +17,14 @@ const ( // Set is not thread-safe, for concurrent use, make sure to use it with synchronization. type Set struct { - data map[interface{}]lang.PlaceholderType + data map[any]lang.PlaceholderType tp int } // NewSet returns a managed Set, can only put the values with the same type. func NewSet() *Set { return &Set{ - data: make(map[interface{}]lang.PlaceholderType), + data: make(map[any]lang.PlaceholderType), tp: untyped, } } @@ -32,13 +32,13 @@ func NewSet() *Set { // NewUnmanagedSet returns an unmanaged Set, which can put values with different types. func NewUnmanagedSet() *Set { return &Set{ - data: make(map[interface{}]lang.PlaceholderType), + data: make(map[any]lang.PlaceholderType), tp: unmanaged, } } // Add adds i into s. -func (s *Set) Add(i ...interface{}) { +func (s *Set) Add(i ...any) { for _, each := range i { s.add(each) } @@ -80,7 +80,7 @@ func (s *Set) AddStr(ss ...string) { } // Contains checks if i is in s. -func (s *Set) Contains(i interface{}) bool { +func (s *Set) Contains(i any) bool { if len(s.data) == 0 { return false } @@ -91,8 +91,8 @@ func (s *Set) Contains(i interface{}) bool { } // Keys returns the keys in s. -func (s *Set) Keys() []interface{} { - var keys []interface{} +func (s *Set) Keys() []any { + var keys []any for key := range s.data { keys = append(keys, key) @@ -167,7 +167,7 @@ func (s *Set) KeysStr() []string { } // Remove removes i from s. -func (s *Set) Remove(i interface{}) { +func (s *Set) Remove(i any) { s.validate(i) delete(s.data, i) } @@ -177,7 +177,7 @@ func (s *Set) Count() int { return len(s.data) } -func (s *Set) add(i interface{}) { +func (s *Set) add(i any) { switch s.tp { case unmanaged: // do nothing @@ -189,7 +189,7 @@ func (s *Set) add(i interface{}) { s.data[i] = lang.Placeholder } -func (s *Set) setType(i interface{}) { +func (s *Set) setType(i any) { // s.tp can only be untyped here switch i.(type) { case int: @@ -205,7 +205,7 @@ func (s *Set) setType(i interface{}) { } } -func (s *Set) validate(i interface{}) { +func (s *Set) validate(i any) { if s.tp == unmanaged { return } diff --git a/core/collection/set_test.go b/core/collection/set_test.go index 3586e151..7baf0a49 100644 --- a/core/collection/set_test.go +++ b/core/collection/set_test.go @@ -13,7 +13,7 @@ func init() { } func BenchmarkRawSet(b *testing.B) { - m := make(map[interface{}]struct{}) + m := make(map[any]struct{}) for i := 0; i < b.N; i++ { m[i] = struct{}{} _ = m[i] @@ -39,7 +39,7 @@ func BenchmarkSet(b *testing.B) { func TestAdd(t *testing.T) { // given set := NewUnmanagedSet() - values := []interface{}{1, 2, 3} + values := []any{1, 2, 3} // when set.Add(values...) @@ -135,7 +135,7 @@ func TestContainsUnmanagedWithoutElements(t *testing.T) { func TestRemove(t *testing.T) { // given set := NewSet() - set.Add([]interface{}{1, 2, 3}...) + set.Add([]any{1, 2, 3}...) // when set.Remove(2) @@ -147,7 +147,7 @@ func TestRemove(t *testing.T) { func TestCount(t *testing.T) { // given set := NewSet() - set.Add([]interface{}{1, 2, 3}...) + set.Add([]any{1, 2, 3}...) // then assert.Equal(t, set.Count(), 3) @@ -198,5 +198,5 @@ func TestSetType(t *testing.T) { set.add(1) set.add("2") vals := set.Keys() - assert.ElementsMatch(t, []interface{}{1, "2"}, vals) + assert.ElementsMatch(t, []any{1, "2"}, vals) } diff --git a/core/collection/timingwheel.go b/core/collection/timingwheel.go index 0763e6f6..5bd8dd28 100644 --- a/core/collection/timingwheel.go +++ b/core/collection/timingwheel.go @@ -20,7 +20,7 @@ var ( type ( // Execute defines the method to execute the task. - Execute func(key, value interface{}) + Execute func(key, value any) // A TimingWheel is a timing wheel object to schedule tasks. TimingWheel struct { @@ -33,14 +33,14 @@ type ( execute Execute setChannel chan timingEntry moveChannel chan baseEntry - removeChannel chan interface{} - drainChannel chan func(key, value interface{}) + removeChannel chan any + drainChannel chan func(key, value any) stopChannel chan lang.PlaceholderType } timingEntry struct { baseEntry - value interface{} + value any circle int diff int removed bool @@ -48,7 +48,7 @@ type ( baseEntry struct { delay time.Duration - key interface{} + key any } positionEntry struct { @@ -57,8 +57,8 @@ type ( } timingTask struct { - key interface{} - value interface{} + key any + value any } ) @@ -85,8 +85,8 @@ func NewTimingWheelWithTicker(interval time.Duration, numSlots int, execute Exec numSlots: numSlots, setChannel: make(chan timingEntry), moveChannel: make(chan baseEntry), - removeChannel: make(chan interface{}), - drainChannel: make(chan func(key, value interface{})), + removeChannel: make(chan any), + drainChannel: make(chan func(key, value any)), stopChannel: make(chan lang.PlaceholderType), } @@ -97,7 +97,7 @@ func NewTimingWheelWithTicker(interval time.Duration, numSlots int, execute Exec } // Drain drains all items and executes them. -func (tw *TimingWheel) Drain(fn func(key, value interface{})) error { +func (tw *TimingWheel) Drain(fn func(key, value any)) error { select { case tw.drainChannel <- fn: return nil @@ -107,7 +107,7 @@ func (tw *TimingWheel) Drain(fn func(key, value interface{})) error { } // MoveTimer moves the task with the given key to the given delay. -func (tw *TimingWheel) MoveTimer(key interface{}, delay time.Duration) error { +func (tw *TimingWheel) MoveTimer(key any, delay time.Duration) error { if delay <= 0 || key == nil { return ErrArgument } @@ -124,7 +124,7 @@ func (tw *TimingWheel) MoveTimer(key interface{}, delay time.Duration) error { } // RemoveTimer removes the task with the given key. -func (tw *TimingWheel) RemoveTimer(key interface{}) error { +func (tw *TimingWheel) RemoveTimer(key any) error { if key == nil { return ErrArgument } @@ -138,7 +138,7 @@ func (tw *TimingWheel) RemoveTimer(key interface{}) error { } // SetTimer sets the task value with the given key to the delay. -func (tw *TimingWheel) SetTimer(key, value interface{}, delay time.Duration) error { +func (tw *TimingWheel) SetTimer(key, value any, delay time.Duration) error { if delay <= 0 || key == nil { return ErrArgument } @@ -162,7 +162,7 @@ func (tw *TimingWheel) Stop() { close(tw.stopChannel) } -func (tw *TimingWheel) drainAll(fn func(key, value interface{})) { +func (tw *TimingWheel) drainAll(fn func(key, value any)) { runner := threading.NewTaskRunner(drainWorkers) for _, slot := range tw.slots { for e := slot.Front(); e != nil; { @@ -232,7 +232,7 @@ func (tw *TimingWheel) onTick() { tw.scanAndRunTasks(l) } -func (tw *TimingWheel) removeTask(key interface{}) { +func (tw *TimingWheel) removeTask(key any) { val, ok := tw.timers.Get(key) if !ok { return diff --git a/core/collection/timingwheel_test.go b/core/collection/timingwheel_test.go index 0ae83b08..c997725f 100644 --- a/core/collection/timingwheel_test.go +++ b/core/collection/timingwheel_test.go @@ -20,13 +20,13 @@ const ( ) func TestNewTimingWheel(t *testing.T) { - _, err := NewTimingWheel(0, 10, func(key, value interface{}) {}) + _, err := NewTimingWheel(0, 10, func(key, value any) {}) assert.NotNil(t, err) } func TestTimingWheel_Drain(t *testing.T) { ticker := timex.NewFakeTicker() - tw, _ := NewTimingWheelWithTicker(testStep, 10, func(k, v interface{}) { + tw, _ := NewTimingWheelWithTicker(testStep, 10, func(k, v any) { }, ticker) tw.SetTimer("first", 3, testStep*4) tw.SetTimer("second", 5, testStep*7) @@ -36,7 +36,7 @@ func TestTimingWheel_Drain(t *testing.T) { var lock sync.Mutex var wg sync.WaitGroup wg.Add(3) - tw.Drain(func(key, value interface{}) { + tw.Drain(func(key, value any) { lock.Lock() defer lock.Unlock() keys = append(keys, key.(string)) @@ -50,19 +50,19 @@ func TestTimingWheel_Drain(t *testing.T) { assert.EqualValues(t, []string{"first", "second", "third"}, keys) assert.EqualValues(t, []int{3, 5, 7}, vals) var count int - tw.Drain(func(key, value interface{}) { + tw.Drain(func(key, value any) { count++ }) time.Sleep(time.Millisecond * 100) assert.Equal(t, 0, count) tw.Stop() - assert.Equal(t, ErrClosed, tw.Drain(func(key, value interface{}) {})) + assert.Equal(t, ErrClosed, tw.Drain(func(key, value any) {})) } func TestTimingWheel_SetTimerSoon(t *testing.T) { run := syncx.NewAtomicBool() ticker := timex.NewFakeTicker() - tw, _ := NewTimingWheelWithTicker(testStep, 10, func(k, v interface{}) { + tw, _ := NewTimingWheelWithTicker(testStep, 10, func(k, v any) { assert.True(t, run.CompareAndSwap(false, true)) assert.Equal(t, "any", k) assert.Equal(t, 3, v.(int)) @@ -78,7 +78,7 @@ func TestTimingWheel_SetTimerSoon(t *testing.T) { func TestTimingWheel_SetTimerTwice(t *testing.T) { run := syncx.NewAtomicBool() ticker := timex.NewFakeTicker() - tw, _ := NewTimingWheelWithTicker(testStep, 10, func(k, v interface{}) { + tw, _ := NewTimingWheelWithTicker(testStep, 10, func(k, v any) { assert.True(t, run.CompareAndSwap(false, true)) assert.Equal(t, "any", k) assert.Equal(t, 5, v.(int)) @@ -96,7 +96,7 @@ func TestTimingWheel_SetTimerTwice(t *testing.T) { func TestTimingWheel_SetTimerWrongDelay(t *testing.T) { ticker := timex.NewFakeTicker() - tw, _ := NewTimingWheelWithTicker(testStep, 10, func(k, v interface{}) {}, ticker) + tw, _ := NewTimingWheelWithTicker(testStep, 10, func(k, v any) {}, ticker) defer tw.Stop() assert.NotPanics(t, func() { tw.SetTimer("any", 3, -testStep) @@ -105,7 +105,7 @@ func TestTimingWheel_SetTimerWrongDelay(t *testing.T) { func TestTimingWheel_SetTimerAfterClose(t *testing.T) { ticker := timex.NewFakeTicker() - tw, _ := NewTimingWheelWithTicker(testStep, 10, func(k, v interface{}) {}, ticker) + tw, _ := NewTimingWheelWithTicker(testStep, 10, func(k, v any) {}, ticker) tw.Stop() assert.Equal(t, ErrClosed, tw.SetTimer("any", 3, testStep)) } @@ -113,7 +113,7 @@ func TestTimingWheel_SetTimerAfterClose(t *testing.T) { func TestTimingWheel_MoveTimer(t *testing.T) { run := syncx.NewAtomicBool() ticker := timex.NewFakeTicker() - tw, _ := NewTimingWheelWithTicker(testStep, 3, func(k, v interface{}) { + tw, _ := NewTimingWheelWithTicker(testStep, 3, func(k, v any) { assert.True(t, run.CompareAndSwap(false, true)) assert.Equal(t, "any", k) assert.Equal(t, 3, v.(int)) @@ -139,7 +139,7 @@ func TestTimingWheel_MoveTimer(t *testing.T) { func TestTimingWheel_MoveTimerSoon(t *testing.T) { run := syncx.NewAtomicBool() ticker := timex.NewFakeTicker() - tw, _ := NewTimingWheelWithTicker(testStep, 3, func(k, v interface{}) { + tw, _ := NewTimingWheelWithTicker(testStep, 3, func(k, v any) { assert.True(t, run.CompareAndSwap(false, true)) assert.Equal(t, "any", k) assert.Equal(t, 3, v.(int)) @@ -155,7 +155,7 @@ func TestTimingWheel_MoveTimerSoon(t *testing.T) { func TestTimingWheel_MoveTimerEarlier(t *testing.T) { run := syncx.NewAtomicBool() ticker := timex.NewFakeTicker() - tw, _ := NewTimingWheelWithTicker(testStep, 10, func(k, v interface{}) { + tw, _ := NewTimingWheelWithTicker(testStep, 10, func(k, v any) { assert.True(t, run.CompareAndSwap(false, true)) assert.Equal(t, "any", k) assert.Equal(t, 3, v.(int)) @@ -173,7 +173,7 @@ func TestTimingWheel_MoveTimerEarlier(t *testing.T) { func TestTimingWheel_RemoveTimer(t *testing.T) { ticker := timex.NewFakeTicker() - tw, _ := NewTimingWheelWithTicker(testStep, 10, func(k, v interface{}) {}, ticker) + tw, _ := NewTimingWheelWithTicker(testStep, 10, func(k, v any) {}, ticker) tw.SetTimer("any", 3, testStep) assert.NotPanics(t, func() { tw.RemoveTimer("any") @@ -236,7 +236,7 @@ func TestTimingWheel_SetTimer(t *testing.T) { } var actual int32 done := make(chan lang.PlaceholderType) - tw, err := NewTimingWheelWithTicker(testStep, test.slots, func(key, value interface{}) { + tw, err := NewTimingWheelWithTicker(testStep, test.slots, func(key, value any) { assert.Equal(t, 1, key.(int)) assert.Equal(t, 2, value.(int)) actual = atomic.LoadInt32(&count) @@ -317,7 +317,7 @@ func TestTimingWheel_SetAndMoveThenStart(t *testing.T) { } var actual int32 done := make(chan lang.PlaceholderType) - tw, err := NewTimingWheelWithTicker(testStep, test.slots, func(key, value interface{}) { + tw, err := NewTimingWheelWithTicker(testStep, test.slots, func(key, value any) { actual = atomic.LoadInt32(&count) close(done) }, ticker) @@ -405,7 +405,7 @@ func TestTimingWheel_SetAndMoveTwice(t *testing.T) { } var actual int32 done := make(chan lang.PlaceholderType) - tw, err := NewTimingWheelWithTicker(testStep, test.slots, func(key, value interface{}) { + tw, err := NewTimingWheelWithTicker(testStep, test.slots, func(key, value any) { actual = atomic.LoadInt32(&count) close(done) }, ticker) @@ -486,7 +486,7 @@ func TestTimingWheel_ElapsedAndSet(t *testing.T) { } var actual int32 done := make(chan lang.PlaceholderType) - tw, err := NewTimingWheelWithTicker(testStep, test.slots, func(key, value interface{}) { + tw, err := NewTimingWheelWithTicker(testStep, test.slots, func(key, value any) { actual = atomic.LoadInt32(&count) close(done) }, ticker) @@ -577,7 +577,7 @@ func TestTimingWheel_ElapsedAndSetThenMove(t *testing.T) { } var actual int32 done := make(chan lang.PlaceholderType) - tw, err := NewTimingWheelWithTicker(testStep, test.slots, func(key, value interface{}) { + tw, err := NewTimingWheelWithTicker(testStep, test.slots, func(key, value any) { actual = atomic.LoadInt32(&count) close(done) }, ticker) @@ -612,7 +612,7 @@ func TestMoveAndRemoveTask(t *testing.T) { } } var keys []int - tw, _ := NewTimingWheelWithTicker(testStep, 10, func(k, v interface{}) { + tw, _ := NewTimingWheelWithTicker(testStep, 10, func(k, v any) { assert.Equal(t, "any", k) assert.Equal(t, 3, v.(int)) keys = append(keys, v.(int)) @@ -632,7 +632,7 @@ func TestMoveAndRemoveTask(t *testing.T) { func BenchmarkTimingWheel(b *testing.B) { b.ReportAllocs() - tw, _ := NewTimingWheel(time.Second, 100, func(k, v interface{}) {}) + tw, _ := NewTimingWheel(time.Second, 100, func(k, v any) {}) for i := 0; i < b.N; i++ { tw.SetTimer(i, i, time.Second) tw.SetTimer(b.N+i, b.N+i, time.Second) diff --git a/core/conf/config.go b/core/conf/config.go index 08e7f90f..b64b9258 100644 --- a/core/conf/config.go +++ b/core/conf/config.go @@ -13,7 +13,7 @@ import ( "github.com/zeromicro/go-zero/internal/encoding" ) -var loaders = map[string]func([]byte, interface{}) error{ +var loaders = map[string]func([]byte, any) error{ ".json": LoadFromJsonBytes, ".toml": LoadFromTomlBytes, ".yaml": LoadFromYamlBytes, @@ -27,7 +27,7 @@ type fieldInfo struct { } // Load loads config into v from file, .json, .yaml and .yml are acceptable. -func Load(file string, v interface{}, opts ...Option) error { +func Load(file string, v any, opts ...Option) error { content, err := os.ReadFile(file) if err != nil { return err @@ -52,13 +52,13 @@ func Load(file string, v interface{}, opts ...Option) error { // LoadConfig loads config into v from file, .json, .yaml and .yml are acceptable. // Deprecated: use Load instead. -func LoadConfig(file string, v interface{}, opts ...Option) error { +func LoadConfig(file string, v any, opts ...Option) error { return Load(file, v, opts...) } // LoadFromJsonBytes loads config into v from content json bytes. -func LoadFromJsonBytes(content []byte, v interface{}) error { - var m map[string]interface{} +func LoadFromJsonBytes(content []byte, v any) error { + var m map[string]any if err := jsonx.Unmarshal(content, &m); err != nil { return err } @@ -71,12 +71,12 @@ func LoadFromJsonBytes(content []byte, v interface{}) error { // LoadConfigFromJsonBytes loads config into v from content json bytes. // Deprecated: use LoadFromJsonBytes instead. -func LoadConfigFromJsonBytes(content []byte, v interface{}) error { +func LoadConfigFromJsonBytes(content []byte, v any) error { return LoadFromJsonBytes(content, v) } // LoadFromTomlBytes loads config into v from content toml bytes. -func LoadFromTomlBytes(content []byte, v interface{}) error { +func LoadFromTomlBytes(content []byte, v any) error { b, err := encoding.TomlToJson(content) if err != nil { return err @@ -86,7 +86,7 @@ func LoadFromTomlBytes(content []byte, v interface{}) error { } // LoadFromYamlBytes loads config into v from content yaml bytes. -func LoadFromYamlBytes(content []byte, v interface{}) error { +func LoadFromYamlBytes(content []byte, v any) error { b, err := encoding.YamlToJson(content) if err != nil { return err @@ -97,12 +97,12 @@ func LoadFromYamlBytes(content []byte, v interface{}) error { // LoadConfigFromYamlBytes loads config into v from content yaml bytes. // Deprecated: use LoadFromYamlBytes instead. -func LoadConfigFromYamlBytes(content []byte, v interface{}) error { +func LoadConfigFromYamlBytes(content []byte, v any) error { return LoadFromYamlBytes(content, v) } // MustLoad loads config into v from path, exits on error. -func MustLoad(path string, v interface{}, opts ...Option) { +func MustLoad(path string, v any, opts ...Option) { if err := Load(path, v, opts...); err != nil { log.Fatalf("error: config file %s, %s", path, err.Error()) } @@ -170,12 +170,12 @@ func toLowerCase(s string) string { return strings.ToLower(s) } -func toLowerCaseInterface(v interface{}, info map[string]fieldInfo) interface{} { +func toLowerCaseInterface(v any, info map[string]fieldInfo) any { switch vv := v.(type) { - case map[string]interface{}: + case map[string]any: return toLowerCaseKeyMap(vv, info) - case []interface{}: - var arr []interface{} + case []any: + var arr []any for _, vvv := range vv { arr = append(arr, toLowerCaseInterface(vvv, info)) } @@ -185,8 +185,8 @@ func toLowerCaseInterface(v interface{}, info map[string]fieldInfo) interface{} } } -func toLowerCaseKeyMap(m map[string]interface{}, info map[string]fieldInfo) map[string]interface{} { - res := make(map[string]interface{}) +func toLowerCaseKeyMap(m map[string]any, info map[string]fieldInfo) map[string]any { + res := make(map[string]any) for k, v := range m { ti, ok := info[k] diff --git a/core/contextx/unmarshaler.go b/core/contextx/unmarshaler.go index 51a40548..a1d7bb38 100644 --- a/core/contextx/unmarshaler.go +++ b/core/contextx/unmarshaler.go @@ -14,13 +14,13 @@ type contextValuer struct { context.Context } -func (cv contextValuer) Value(key string) (interface{}, bool) { +func (cv contextValuer) Value(key string) (any, bool) { v := cv.Context.Value(key) return v, v != nil } // For unmarshals ctx into v. -func For(ctx context.Context, v interface{}) error { +func For(ctx context.Context, v any) error { return unmarshaler.UnmarshalValuer(contextValuer{ Context: ctx, }, v) diff --git a/core/discov/internal/etcdclient_mock.go b/core/discov/internal/etcdclient_mock.go index 203a6c27..7b7de816 100644 --- a/core/discov/internal/etcdclient_mock.go +++ b/core/discov/internal/etcdclient_mock.go @@ -81,7 +81,7 @@ func (mr *MockEtcdClientMockRecorder) Ctx() *gomock.Call { // Get mocks base method func (m *MockEtcdClient) Get(ctx context.Context, key string, opts ...clientv3.OpOption) (*clientv3.GetResponse, error) { m.ctrl.T.Helper() - varargs := []interface{}{ctx, key} + varargs := []any{ctx, key} for _, a := range opts { varargs = append(varargs, a) } @@ -92,9 +92,9 @@ func (m *MockEtcdClient) Get(ctx context.Context, key string, opts ...clientv3.O } // Get indicates an expected call of Get -func (mr *MockEtcdClientMockRecorder) Get(ctx, key interface{}, opts ...interface{}) *gomock.Call { +func (mr *MockEtcdClientMockRecorder) Get(ctx, key any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{ctx, key}, opts...) + varargs := append([]any{ctx, key}, opts...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockEtcdClient)(nil).Get), varargs...) } @@ -108,7 +108,7 @@ func (m *MockEtcdClient) Grant(ctx context.Context, ttl int64) (*clientv3.LeaseG } // Grant indicates an expected call of Grant -func (mr *MockEtcdClientMockRecorder) Grant(ctx, ttl interface{}) *gomock.Call { +func (mr *MockEtcdClientMockRecorder) Grant(ctx, ttl any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Grant", reflect.TypeOf((*MockEtcdClient)(nil).Grant), ctx, ttl) } @@ -123,7 +123,7 @@ func (m *MockEtcdClient) KeepAlive(ctx context.Context, id clientv3.LeaseID) (<- } // KeepAlive indicates an expected call of KeepAlive -func (mr *MockEtcdClientMockRecorder) KeepAlive(ctx, id interface{}) *gomock.Call { +func (mr *MockEtcdClientMockRecorder) KeepAlive(ctx, id any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "KeepAlive", reflect.TypeOf((*MockEtcdClient)(nil).KeepAlive), ctx, id) } @@ -131,7 +131,7 @@ func (mr *MockEtcdClientMockRecorder) KeepAlive(ctx, id interface{}) *gomock.Cal // Put mocks base method func (m *MockEtcdClient) Put(ctx context.Context, key, val string, opts ...clientv3.OpOption) (*clientv3.PutResponse, error) { m.ctrl.T.Helper() - varargs := []interface{}{ctx, key, val} + varargs := []any{ctx, key, val} for _, a := range opts { varargs = append(varargs, a) } @@ -142,9 +142,9 @@ func (m *MockEtcdClient) Put(ctx context.Context, key, val string, opts ...clien } // Put indicates an expected call of Put -func (mr *MockEtcdClientMockRecorder) Put(ctx, key, val interface{}, opts ...interface{}) *gomock.Call { +func (mr *MockEtcdClientMockRecorder) Put(ctx, key, val any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{ctx, key, val}, opts...) + varargs := append([]any{ctx, key, val}, opts...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Put", reflect.TypeOf((*MockEtcdClient)(nil).Put), varargs...) } @@ -158,7 +158,7 @@ func (m *MockEtcdClient) Revoke(ctx context.Context, id clientv3.LeaseID) (*clie } // Revoke indicates an expected call of Revoke -func (mr *MockEtcdClientMockRecorder) Revoke(ctx, id interface{}) *gomock.Call { +func (mr *MockEtcdClientMockRecorder) Revoke(ctx, id any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Revoke", reflect.TypeOf((*MockEtcdClient)(nil).Revoke), ctx, id) } @@ -166,7 +166,7 @@ func (mr *MockEtcdClientMockRecorder) Revoke(ctx, id interface{}) *gomock.Call { // Watch mocks base method func (m *MockEtcdClient) Watch(ctx context.Context, key string, opts ...clientv3.OpOption) clientv3.WatchChan { m.ctrl.T.Helper() - varargs := []interface{}{ctx, key} + varargs := []any{ctx, key} for _, a := range opts { varargs = append(varargs, a) } @@ -176,8 +176,8 @@ func (m *MockEtcdClient) Watch(ctx context.Context, key string, opts ...clientv3 } // Watch indicates an expected call of Watch -func (mr *MockEtcdClientMockRecorder) Watch(ctx, key interface{}, opts ...interface{}) *gomock.Call { +func (mr *MockEtcdClientMockRecorder) Watch(ctx, key any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{ctx, key}, opts...) + varargs := append([]any{ctx, key}, opts...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Watch", reflect.TypeOf((*MockEtcdClient)(nil).Watch), varargs...) } diff --git a/core/discov/internal/registry_test.go b/core/discov/internal/registry_test.go index 0ebc00ca..21b06062 100644 --- a/core/discov/internal/registry_test.go +++ b/core/discov/internal/registry_test.go @@ -167,7 +167,7 @@ func TestCluster_Watch(t *testing.T) { assert.Equal(t, "world", kv.Val) wg.Done() }).MaxTimes(1) - listener.EXPECT().OnDelete(gomock.Any()).Do(func(_ interface{}) { + listener.EXPECT().OnDelete(gomock.Any()).Do(func(_ any) { wg.Done() }).MaxTimes(1) go c.watch(cli, "any", 0) diff --git a/core/discov/internal/statewatcher_mock.go b/core/discov/internal/statewatcher_mock.go index 6450c7aa..2d1bd3a3 100644 --- a/core/discov/internal/statewatcher_mock.go +++ b/core/discov/internal/statewatcher_mock.go @@ -58,7 +58,7 @@ func (m *MocketcdConn) WaitForStateChange(ctx context.Context, sourceState conne } // WaitForStateChange indicates an expected call of WaitForStateChange -func (mr *MocketcdConnMockRecorder) WaitForStateChange(ctx, sourceState interface{}) *gomock.Call { +func (mr *MocketcdConnMockRecorder) WaitForStateChange(ctx, sourceState any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WaitForStateChange", reflect.TypeOf((*MocketcdConn)(nil).WaitForStateChange), ctx, sourceState) } diff --git a/core/discov/internal/updatelistener_mock.go b/core/discov/internal/updatelistener_mock.go index ae983e3c..577cd703 100644 --- a/core/discov/internal/updatelistener_mock.go +++ b/core/discov/internal/updatelistener_mock.go @@ -40,7 +40,7 @@ func (m *MockUpdateListener) OnAdd(kv KV) { } // OnAdd indicates an expected call of OnAdd -func (mr *MockUpdateListenerMockRecorder) OnAdd(kv interface{}) *gomock.Call { +func (mr *MockUpdateListenerMockRecorder) OnAdd(kv any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnAdd", reflect.TypeOf((*MockUpdateListener)(nil).OnAdd), kv) } @@ -52,7 +52,7 @@ func (m *MockUpdateListener) OnDelete(kv KV) { } // OnDelete indicates an expected call of OnDelete -func (mr *MockUpdateListenerMockRecorder) OnDelete(kv interface{}) *gomock.Call { +func (mr *MockUpdateListenerMockRecorder) OnDelete(kv any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnDelete", reflect.TypeOf((*MockUpdateListener)(nil).OnDelete), kv) } diff --git a/core/discov/publisher_test.go b/core/discov/publisher_test.go index fd8aaabb..61dc2362 100644 --- a/core/discov/publisher_test.go +++ b/core/discov/publisher_test.go @@ -125,7 +125,7 @@ func TestPublisher_keepAliveAsyncQuit(t *testing.T) { cli.EXPECT().KeepAlive(gomock.Any(), id) var wg sync.WaitGroup wg.Add(1) - cli.EXPECT().Revoke(gomock.Any(), id).Do(func(_, _ interface{}) { + cli.EXPECT().Revoke(gomock.Any(), id).Do(func(_, _ any) { wg.Done() }) pub := NewPublisher(nil, "thekey", "thevalue") @@ -147,7 +147,7 @@ func TestPublisher_keepAliveAsyncPause(t *testing.T) { pub := NewPublisher(nil, "thekey", "thevalue") var wg sync.WaitGroup wg.Add(1) - cli.EXPECT().Revoke(gomock.Any(), id).Do(func(_, _ interface{}) { + cli.EXPECT().Revoke(gomock.Any(), id).Do(func(_, _ any) { pub.Stop() wg.Done() }) diff --git a/core/errorx/wrap.go b/core/errorx/wrap.go index f4c7da66..67e86171 100644 --- a/core/errorx/wrap.go +++ b/core/errorx/wrap.go @@ -12,7 +12,7 @@ func Wrap(err error, message string) error { } // Wrapf returns an error that wraps err with given format and args. -func Wrapf(err error, format string, args ...interface{}) error { +func Wrapf(err error, format string, args ...any) error { if err == nil { return nil } diff --git a/core/executors/bulkexecutor.go b/core/executors/bulkexecutor.go index c1de4b5c..8e96ae10 100644 --- a/core/executors/bulkexecutor.go +++ b/core/executors/bulkexecutor.go @@ -42,7 +42,7 @@ func NewBulkExecutor(execute Execute, opts ...BulkOption) *BulkExecutor { } // Add adds task into be. -func (be *BulkExecutor) Add(task interface{}) error { +func (be *BulkExecutor) Add(task any) error { be.executor.Add(task) return nil } @@ -79,22 +79,22 @@ func newBulkOptions() bulkOptions { } type bulkContainer struct { - tasks []interface{} + tasks []any execute Execute maxTasks int } -func (bc *bulkContainer) AddTask(task interface{}) bool { +func (bc *bulkContainer) AddTask(task any) bool { bc.tasks = append(bc.tasks, task) return len(bc.tasks) >= bc.maxTasks } -func (bc *bulkContainer) Execute(tasks interface{}) { - vals := tasks.([]interface{}) +func (bc *bulkContainer) Execute(tasks any) { + vals := tasks.([]any) bc.execute(vals) } -func (bc *bulkContainer) RemoveAll() interface{} { +func (bc *bulkContainer) RemoveAll() any { tasks := bc.tasks bc.tasks = nil return tasks diff --git a/core/executors/bulkexecutor_test.go b/core/executors/bulkexecutor_test.go index f8a33d9a..e634c63b 100644 --- a/core/executors/bulkexecutor_test.go +++ b/core/executors/bulkexecutor_test.go @@ -12,7 +12,7 @@ func TestBulkExecutor(t *testing.T) { var values []int var lock sync.Mutex - executor := NewBulkExecutor(func(items []interface{}) { + executor := NewBulkExecutor(func(items []any) { lock.Lock() values = append(values, len(items)) lock.Unlock() @@ -40,7 +40,7 @@ func TestBulkExecutorFlushInterval(t *testing.T) { var wait sync.WaitGroup wait.Add(1) - executor := NewBulkExecutor(func(items []interface{}) { + executor := NewBulkExecutor(func(items []any) { assert.Equal(t, size, len(items)) wait.Done() }, WithBulkTasks(caches), WithBulkInterval(time.Millisecond*100)) @@ -53,7 +53,7 @@ func TestBulkExecutorFlushInterval(t *testing.T) { } func TestBulkExecutorEmpty(t *testing.T) { - NewBulkExecutor(func(items []interface{}) { + NewBulkExecutor(func(items []any) { assert.Fail(t, "should not called") }, WithBulkTasks(10), WithBulkInterval(time.Millisecond)) time.Sleep(time.Millisecond * 100) @@ -67,7 +67,7 @@ func TestBulkExecutorFlush(t *testing.T) { var wait sync.WaitGroup wait.Add(1) - be := NewBulkExecutor(func(items []interface{}) { + be := NewBulkExecutor(func(items []any) { assert.Equal(t, tasks, len(items)) wait.Done() }, WithBulkTasks(caches), WithBulkInterval(time.Minute)) @@ -81,8 +81,8 @@ func TestBulkExecutorFlush(t *testing.T) { func TestBuldExecutorFlushSlowTasks(t *testing.T) { const total = 1500 lock := new(sync.Mutex) - result := make([]interface{}, 0, 10000) - exec := NewBulkExecutor(func(tasks []interface{}) { + result := make([]any, 0, 10000) + exec := NewBulkExecutor(func(tasks []any) { time.Sleep(time.Millisecond * 100) lock.Lock() defer lock.Unlock() @@ -100,7 +100,7 @@ func TestBuldExecutorFlushSlowTasks(t *testing.T) { func BenchmarkBulkExecutor(b *testing.B) { b.ReportAllocs() - be := NewBulkExecutor(func(tasks []interface{}) { + be := NewBulkExecutor(func(tasks []any) { time.Sleep(time.Millisecond * time.Duration(len(tasks))) }) for i := 0; i < b.N; i++ { diff --git a/core/executors/chunkexecutor.go b/core/executors/chunkexecutor.go index b78ec339..6255f565 100644 --- a/core/executors/chunkexecutor.go +++ b/core/executors/chunkexecutor.go @@ -42,7 +42,7 @@ func NewChunkExecutor(execute Execute, opts ...ChunkOption) *ChunkExecutor { } // Add adds task with given chunk size into ce. -func (ce *ChunkExecutor) Add(task interface{}, size int) error { +func (ce *ChunkExecutor) Add(task any, size int) error { ce.executor.Add(chunk{ val: task, size: size, @@ -82,25 +82,25 @@ func newChunkOptions() chunkOptions { } type chunkContainer struct { - tasks []interface{} + tasks []any execute Execute size int maxChunkSize int } -func (bc *chunkContainer) AddTask(task interface{}) bool { +func (bc *chunkContainer) AddTask(task any) bool { ck := task.(chunk) bc.tasks = append(bc.tasks, ck.val) bc.size += ck.size return bc.size >= bc.maxChunkSize } -func (bc *chunkContainer) Execute(tasks interface{}) { - vals := tasks.([]interface{}) +func (bc *chunkContainer) Execute(tasks any) { + vals := tasks.([]any) bc.execute(vals) } -func (bc *chunkContainer) RemoveAll() interface{} { +func (bc *chunkContainer) RemoveAll() any { tasks := bc.tasks bc.tasks = nil bc.size = 0 @@ -108,6 +108,6 @@ func (bc *chunkContainer) RemoveAll() interface{} { } type chunk struct { - val interface{} + val any size int } diff --git a/core/executors/chunkexecutor_test.go b/core/executors/chunkexecutor_test.go index cd013b82..c4287b79 100644 --- a/core/executors/chunkexecutor_test.go +++ b/core/executors/chunkexecutor_test.go @@ -12,7 +12,7 @@ func TestChunkExecutor(t *testing.T) { var values []int var lock sync.Mutex - executor := NewChunkExecutor(func(items []interface{}) { + executor := NewChunkExecutor(func(items []any) { lock.Lock() values = append(values, len(items)) lock.Unlock() @@ -40,7 +40,7 @@ func TestChunkExecutorFlushInterval(t *testing.T) { var wait sync.WaitGroup wait.Add(1) - executor := NewChunkExecutor(func(items []interface{}) { + executor := NewChunkExecutor(func(items []any) { assert.Equal(t, size, len(items)) wait.Done() }, WithChunkBytes(caches), WithFlushInterval(time.Millisecond*100)) @@ -53,7 +53,7 @@ func TestChunkExecutorFlushInterval(t *testing.T) { } func TestChunkExecutorEmpty(t *testing.T) { - executor := NewChunkExecutor(func(items []interface{}) { + executor := NewChunkExecutor(func(items []any) { assert.Fail(t, "should not called") }, WithChunkBytes(10), WithFlushInterval(time.Millisecond)) time.Sleep(time.Millisecond * 100) @@ -68,7 +68,7 @@ func TestChunkExecutorFlush(t *testing.T) { var wait sync.WaitGroup wait.Add(1) - be := NewChunkExecutor(func(items []interface{}) { + be := NewChunkExecutor(func(items []any) { assert.Equal(t, tasks, len(items)) wait.Done() }, WithChunkBytes(caches), WithFlushInterval(time.Minute)) @@ -82,7 +82,7 @@ func TestChunkExecutorFlush(t *testing.T) { func BenchmarkChunkExecutor(b *testing.B) { b.ReportAllocs() - be := NewChunkExecutor(func(tasks []interface{}) { + be := NewChunkExecutor(func(tasks []any) { time.Sleep(time.Millisecond * time.Duration(len(tasks))) }) for i := 0; i < b.N; i++ { diff --git a/core/executors/periodicalexecutor.go b/core/executors/periodicalexecutor.go index db0ccd82..649afe14 100644 --- a/core/executors/periodicalexecutor.go +++ b/core/executors/periodicalexecutor.go @@ -21,16 +21,16 @@ type ( TaskContainer interface { // AddTask adds the task into the container. // Returns true if the container needs to be flushed after the addition. - AddTask(task interface{}) bool + AddTask(task any) bool // Execute handles the collected tasks by the container when flushing. - Execute(tasks interface{}) + Execute(tasks any) // RemoveAll removes the contained tasks, and return them. - RemoveAll() interface{} + RemoveAll() any } // A PeriodicalExecutor is an executor that periodically execute tasks. PeriodicalExecutor struct { - commander chan interface{} + commander chan any interval time.Duration container TaskContainer waitGroup sync.WaitGroup @@ -48,7 +48,7 @@ type ( func NewPeriodicalExecutor(interval time.Duration, container TaskContainer) *PeriodicalExecutor { executor := &PeriodicalExecutor{ // buffer 1 to let the caller go quickly - commander: make(chan interface{}, 1), + commander: make(chan any, 1), interval: interval, container: container, confirmChan: make(chan lang.PlaceholderType), @@ -64,7 +64,7 @@ func NewPeriodicalExecutor(interval time.Duration, container TaskContainer) *Per } // Add adds tasks into pe. -func (pe *PeriodicalExecutor) Add(task interface{}) { +func (pe *PeriodicalExecutor) Add(task any) { if vals, ok := pe.addAndCheck(task); ok { pe.commander <- vals <-pe.confirmChan @@ -74,7 +74,7 @@ func (pe *PeriodicalExecutor) Add(task interface{}) { // Flush forces pe to execute tasks. func (pe *PeriodicalExecutor) Flush() bool { pe.enterExecution() - return pe.executeTasks(func() interface{} { + return pe.executeTasks(func() any { pe.lock.Lock() defer pe.lock.Unlock() return pe.container.RemoveAll() @@ -96,7 +96,7 @@ func (pe *PeriodicalExecutor) Wait() { }) } -func (pe *PeriodicalExecutor) addAndCheck(task interface{}) (interface{}, bool) { +func (pe *PeriodicalExecutor) addAndCheck(task any) (any, bool) { pe.lock.Lock() defer func() { if !pe.guarded { @@ -157,7 +157,7 @@ func (pe *PeriodicalExecutor) enterExecution() { }) } -func (pe *PeriodicalExecutor) executeTasks(tasks interface{}) bool { +func (pe *PeriodicalExecutor) executeTasks(tasks any) bool { defer pe.doneExecution() ok := pe.hasTasks(tasks) @@ -168,7 +168,7 @@ func (pe *PeriodicalExecutor) executeTasks(tasks interface{}) bool { return ok } -func (pe *PeriodicalExecutor) hasTasks(tasks interface{}) bool { +func (pe *PeriodicalExecutor) hasTasks(tasks any) bool { if tasks == nil { return false } diff --git a/core/executors/periodicalexecutor_test.go b/core/executors/periodicalexecutor_test.go index 8815484b..32f5bd10 100644 --- a/core/executors/periodicalexecutor_test.go +++ b/core/executors/periodicalexecutor_test.go @@ -17,22 +17,22 @@ const threshold = 10 type container struct { interval time.Duration tasks []int - execute func(tasks interface{}) + execute func(tasks any) } -func newContainer(interval time.Duration, execute func(tasks interface{})) *container { +func newContainer(interval time.Duration, execute func(tasks any)) *container { return &container{ interval: interval, execute: execute, } } -func (c *container) AddTask(task interface{}) bool { +func (c *container) AddTask(task any) bool { c.tasks = append(c.tasks, task.(int)) return len(c.tasks) > threshold } -func (c *container) Execute(tasks interface{}) { +func (c *container) Execute(tasks any) { if c.execute != nil { c.execute(tasks) } else { @@ -40,7 +40,7 @@ func (c *container) Execute(tasks interface{}) { } } -func (c *container) RemoveAll() interface{} { +func (c *container) RemoveAll() any { tasks := c.tasks c.tasks = nil return tasks @@ -76,7 +76,7 @@ func TestPeriodicalExecutor_Bulk(t *testing.T) { var vals []int // avoid data race var lock sync.Mutex - exec := NewPeriodicalExecutor(time.Millisecond, newContainer(time.Millisecond, func(tasks interface{}) { + exec := NewPeriodicalExecutor(time.Millisecond, newContainer(time.Millisecond, func(tasks any) { t := tasks.([]int) for _, each := range t { lock.Lock() @@ -110,7 +110,7 @@ func TestPeriodicalExecutor_Bulk(t *testing.T) { func TestPeriodicalExecutor_Wait(t *testing.T) { var lock sync.Mutex - executer := NewBulkExecutor(func(tasks []interface{}) { + executer := NewBulkExecutor(func(tasks []any) { lock.Lock() defer lock.Unlock() time.Sleep(10 * time.Millisecond) @@ -126,7 +126,7 @@ func TestPeriodicalExecutor_WaitFast(t *testing.T) { const total = 3 var cnt int var lock sync.Mutex - executer := NewBulkExecutor(func(tasks []interface{}) { + executer := NewBulkExecutor(func(tasks []any) { defer func() { cnt++ }() @@ -143,7 +143,7 @@ func TestPeriodicalExecutor_WaitFast(t *testing.T) { } func TestPeriodicalExecutor_Deadlock(t *testing.T) { - executor := NewBulkExecutor(func(tasks []interface{}) { + executor := NewBulkExecutor(func(tasks []any) { }, WithBulkTasks(1), WithBulkInterval(time.Millisecond)) for i := 0; i < 1e5; i++ { executor.Add(1) diff --git a/core/executors/vars.go b/core/executors/vars.go index fa0ab9d5..5bec79fe 100644 --- a/core/executors/vars.go +++ b/core/executors/vars.go @@ -5,4 +5,4 @@ import "time" const defaultFlushInterval = time.Second // Execute defines the method to execute tasks. -type Execute func(tasks []interface{}) +type Execute func(tasks []any) diff --git a/core/fx/stream.go b/core/fx/stream.go index af235f12..44495f87 100644 --- a/core/fx/stream.go +++ b/core/fx/stream.go @@ -21,31 +21,31 @@ type ( } // FilterFunc defines the method to filter a Stream. - FilterFunc func(item interface{}) bool + FilterFunc func(item any) bool // ForAllFunc defines the method to handle all elements in a Stream. - ForAllFunc func(pipe <-chan interface{}) + ForAllFunc func(pipe <-chan any) // ForEachFunc defines the method to handle each element in a Stream. - ForEachFunc func(item interface{}) + ForEachFunc func(item any) // GenerateFunc defines the method to send elements into a Stream. - GenerateFunc func(source chan<- interface{}) + GenerateFunc func(source chan<- any) // KeyFunc defines the method to generate keys for the elements in a Stream. - KeyFunc func(item interface{}) interface{} + KeyFunc func(item any) any // LessFunc defines the method to compare the elements in a Stream. - LessFunc func(a, b interface{}) bool + LessFunc func(a, b any) bool // MapFunc defines the method to map each element to another object in a Stream. - MapFunc func(item interface{}) interface{} + MapFunc func(item any) any // Option defines the method to customize a Stream. Option func(opts *rxOptions) // ParallelFunc defines the method to handle elements parallelly. - ParallelFunc func(item interface{}) + ParallelFunc func(item any) // ReduceFunc defines the method to reduce all the elements in a Stream. - ReduceFunc func(pipe <-chan interface{}) (interface{}, error) + ReduceFunc func(pipe <-chan any) (any, error) // WalkFunc defines the method to walk through all the elements in a Stream. - WalkFunc func(item interface{}, pipe chan<- interface{}) + WalkFunc func(item any, pipe chan<- any) // A Stream is a stream that can be used to do stream processing. Stream struct { - source <-chan interface{} + source <-chan any } ) @@ -56,7 +56,7 @@ func Concat(s Stream, others ...Stream) Stream { // From constructs a Stream from the given GenerateFunc. func From(generate GenerateFunc) Stream { - source := make(chan interface{}) + source := make(chan any) threading.GoSafe(func() { defer close(source) @@ -67,8 +67,8 @@ func From(generate GenerateFunc) Stream { } // Just converts the given arbitrary items to a Stream. -func Just(items ...interface{}) Stream { - source := make(chan interface{}, len(items)) +func Just(items ...any) Stream { + source := make(chan any, len(items)) for _, item := range items { source <- item } @@ -78,7 +78,7 @@ func Just(items ...interface{}) Stream { } // Range converts the given channel to a Stream. -func Range(source <-chan interface{}) Stream { +func Range(source <-chan any) Stream { return Stream{ source: source, } @@ -87,7 +87,7 @@ func Range(source <-chan interface{}) Stream { // AllMach returns whether all elements of this stream match the provided predicate. // May not evaluate the predicate on all elements if not necessary for determining the result. // If the stream is empty then true is returned and the predicate is not evaluated. -func (s Stream) AllMach(predicate func(item interface{}) bool) bool { +func (s Stream) AllMach(predicate func(item any) bool) bool { for item := range s.source { if !predicate(item) { // make sure the former goroutine not block, and current func returns fast. @@ -102,7 +102,7 @@ func (s Stream) AllMach(predicate func(item interface{}) bool) bool { // AnyMach returns whether any elements of this stream match the provided predicate. // May not evaluate the predicate on all elements if not necessary for determining the result. // If the stream is empty then false is returned and the predicate is not evaluated. -func (s Stream) AnyMach(predicate func(item interface{}) bool) bool { +func (s Stream) AnyMach(predicate func(item any) bool) bool { for item := range s.source { if predicate(item) { // make sure the former goroutine not block, and current func returns fast. @@ -121,7 +121,7 @@ func (s Stream) Buffer(n int) Stream { n = 0 } - source := make(chan interface{}, n) + source := make(chan any, n) go func() { for item := range s.source { source <- item @@ -134,7 +134,7 @@ func (s Stream) Buffer(n int) Stream { // Concat returns a Stream that concatenated other streams func (s Stream) Concat(others ...Stream) Stream { - source := make(chan interface{}) + source := make(chan any) go func() { group := threading.NewRoutineGroup() @@ -170,12 +170,12 @@ func (s Stream) Count() (count int) { // Distinct removes the duplicated items base on the given KeyFunc. func (s Stream) Distinct(fn KeyFunc) Stream { - source := make(chan interface{}) + source := make(chan any) threading.GoSafe(func() { defer close(source) - keys := make(map[interface{}]lang.PlaceholderType) + keys := make(map[any]lang.PlaceholderType) for item := range s.source { key := fn(item) if _, ok := keys[key]; !ok { @@ -195,7 +195,7 @@ func (s Stream) Done() { // Filter filters the items by the given FilterFunc. func (s Stream) Filter(fn FilterFunc, opts ...Option) Stream { - return s.Walk(func(item interface{}, pipe chan<- interface{}) { + return s.Walk(func(item any, pipe chan<- any) { if fn(item) { pipe <- item } @@ -203,7 +203,7 @@ func (s Stream) Filter(fn FilterFunc, opts ...Option) Stream { } // First returns the first item, nil if no items. -func (s Stream) First() interface{} { +func (s Stream) First() any { for item := range s.source { // make sure the former goroutine not block, and current func returns fast. go drain(s.source) @@ -229,13 +229,13 @@ func (s Stream) ForEach(fn ForEachFunc) { // Group groups the elements into different groups based on their keys. func (s Stream) Group(fn KeyFunc) Stream { - groups := make(map[interface{}][]interface{}) + groups := make(map[any][]any) for item := range s.source { key := fn(item) groups[key] = append(groups[key], item) } - source := make(chan interface{}) + source := make(chan any) go func() { for _, group := range groups { source <- group @@ -252,7 +252,7 @@ func (s Stream) Head(n int64) Stream { panic("n must be greater than 0") } - source := make(chan interface{}) + source := make(chan any) go func() { for item := range s.source { @@ -279,7 +279,7 @@ func (s Stream) Head(n int64) Stream { } // Last returns the last item, or nil if no items. -func (s Stream) Last() (item interface{}) { +func (s Stream) Last() (item any) { for item = range s.source { } return @@ -287,19 +287,19 @@ func (s Stream) Last() (item interface{}) { // Map converts each item to another corresponding item, which means it's a 1:1 model. func (s Stream) Map(fn MapFunc, opts ...Option) Stream { - return s.Walk(func(item interface{}, pipe chan<- interface{}) { + return s.Walk(func(item any, pipe chan<- any) { pipe <- fn(item) }, opts...) } // Merge merges all the items into a slice and generates a new stream. func (s Stream) Merge() Stream { - var items []interface{} + var items []any for item := range s.source { items = append(items, item) } - source := make(chan interface{}, 1) + source := make(chan any, 1) source <- items close(source) @@ -309,7 +309,7 @@ func (s Stream) Merge() Stream { // NoneMatch returns whether all elements of this stream don't match the provided predicate. // May not evaluate the predicate on all elements if not necessary for determining the result. // If the stream is empty then true is returned and the predicate is not evaluated. -func (s Stream) NoneMatch(predicate func(item interface{}) bool) bool { +func (s Stream) NoneMatch(predicate func(item any) bool) bool { for item := range s.source { if predicate(item) { // make sure the former goroutine not block, and current func returns fast. @@ -323,19 +323,19 @@ func (s Stream) NoneMatch(predicate func(item interface{}) bool) bool { // Parallel applies the given ParallelFunc to each item concurrently with given number of workers. func (s Stream) Parallel(fn ParallelFunc, opts ...Option) { - s.Walk(func(item interface{}, pipe chan<- interface{}) { + s.Walk(func(item any, pipe chan<- any) { fn(item) }, opts...).Done() } // Reduce is an utility method to let the caller deal with the underlying channel. -func (s Stream) Reduce(fn ReduceFunc) (interface{}, error) { +func (s Stream) Reduce(fn ReduceFunc) (any, error) { return fn(s.source) } // Reverse reverses the elements in the stream. func (s Stream) Reverse() Stream { - var items []interface{} + var items []any for item := range s.source { items = append(items, item) } @@ -357,7 +357,7 @@ func (s Stream) Skip(n int64) Stream { return s } - source := make(chan interface{}) + source := make(chan any) go func() { for item := range s.source { @@ -376,7 +376,7 @@ func (s Stream) Skip(n int64) Stream { // Sort sorts the items from the underlying source. func (s Stream) Sort(less LessFunc) Stream { - var items []interface{} + var items []any for item := range s.source { items = append(items, item) } @@ -394,9 +394,9 @@ func (s Stream) Split(n int) Stream { panic("n should be greater than 0") } - source := make(chan interface{}) + source := make(chan any) go func() { - var chunk []interface{} + var chunk []any for item := range s.source { chunk = append(chunk, item) if len(chunk) == n { @@ -419,7 +419,7 @@ func (s Stream) Tail(n int64) Stream { panic("n should be greater than 0") } - source := make(chan interface{}) + source := make(chan any) go func() { ring := collection.NewRing(int(n)) @@ -446,7 +446,7 @@ func (s Stream) Walk(fn WalkFunc, opts ...Option) Stream { } func (s Stream) walkLimited(fn WalkFunc, option *rxOptions) Stream { - pipe := make(chan interface{}, option.workers) + pipe := make(chan any, option.workers) go func() { var wg sync.WaitGroup @@ -477,7 +477,7 @@ func (s Stream) walkLimited(fn WalkFunc, option *rxOptions) Stream { } func (s Stream) walkUnlimited(fn WalkFunc, option *rxOptions) Stream { - pipe := make(chan interface{}, option.workers) + pipe := make(chan any, option.workers) go func() { var wg sync.WaitGroup @@ -529,7 +529,7 @@ func buildOptions(opts ...Option) *rxOptions { } // drain drains the given channel. -func drain(channel <-chan interface{}) { +func drain(channel <-chan any) { for range channel { } } diff --git a/core/fx/stream_test.go b/core/fx/stream_test.go index 993cbe7e..dd58d3e6 100644 --- a/core/fx/stream_test.go +++ b/core/fx/stream_test.go @@ -23,7 +23,7 @@ func TestBuffer(t *testing.T) { var count int32 var wait sync.WaitGroup wait.Add(1) - From(func(source chan<- interface{}) { + From(func(source chan<- any) { ticker := time.NewTicker(10 * time.Millisecond) defer ticker.Stop() @@ -36,7 +36,7 @@ func TestBuffer(t *testing.T) { return } } - }).Buffer(N).ForAll(func(pipe <-chan interface{}) { + }).Buffer(N).ForAll(func(pipe <-chan any) { wait.Wait() // why N+1, because take one more to wait for sending into the channel assert.Equal(t, int32(N+1), atomic.LoadInt32(&count)) @@ -47,7 +47,7 @@ func TestBuffer(t *testing.T) { func TestBufferNegative(t *testing.T) { runCheckedTest(t, func(t *testing.T) { var result int - Just(1, 2, 3, 4).Buffer(-1).Reduce(func(pipe <-chan interface{}) (interface{}, error) { + Just(1, 2, 3, 4).Buffer(-1).Reduce(func(pipe <-chan any) (any, error) { for item := range pipe { result += item.(int) } @@ -61,22 +61,22 @@ func TestCount(t *testing.T) { runCheckedTest(t, func(t *testing.T) { tests := []struct { name string - elements []interface{} + elements []any }{ { name: "no elements with nil", }, { name: "no elements", - elements: []interface{}{}, + elements: []any{}, }, { name: "1 element", - elements: []interface{}{1}, + elements: []any{1}, }, { name: "multiple elements", - elements: []interface{}{1, 2, 3}, + elements: []any{1, 2, 3}, }, } @@ -92,7 +92,7 @@ func TestCount(t *testing.T) { func TestDone(t *testing.T) { runCheckedTest(t, func(t *testing.T) { var count int32 - Just(1, 2, 3).Walk(func(item interface{}, pipe chan<- interface{}) { + Just(1, 2, 3).Walk(func(item any, pipe chan<- any) { time.Sleep(time.Millisecond * 100) atomic.AddInt32(&count, int32(item.(int))) }).Done() @@ -103,7 +103,7 @@ func TestDone(t *testing.T) { func TestJust(t *testing.T) { runCheckedTest(t, func(t *testing.T) { var result int - Just(1, 2, 3, 4).Reduce(func(pipe <-chan interface{}) (interface{}, error) { + Just(1, 2, 3, 4).Reduce(func(pipe <-chan any) (any, error) { for item := range pipe { result += item.(int) } @@ -116,9 +116,9 @@ func TestJust(t *testing.T) { func TestDistinct(t *testing.T) { runCheckedTest(t, func(t *testing.T) { var result int - Just(4, 1, 3, 2, 3, 4).Distinct(func(item interface{}) interface{} { + Just(4, 1, 3, 2, 3, 4).Distinct(func(item any) any { return item - }).Reduce(func(pipe <-chan interface{}) (interface{}, error) { + }).Reduce(func(pipe <-chan any) (any, error) { for item := range pipe { result += item.(int) } @@ -131,9 +131,9 @@ func TestDistinct(t *testing.T) { func TestFilter(t *testing.T) { runCheckedTest(t, func(t *testing.T) { var result int - Just(1, 2, 3, 4).Filter(func(item interface{}) bool { + Just(1, 2, 3, 4).Filter(func(item any) bool { return item.(int)%2 == 0 - }).Reduce(func(pipe <-chan interface{}) (interface{}, error) { + }).Reduce(func(pipe <-chan any) (any, error) { for item := range pipe { result += item.(int) } @@ -154,9 +154,9 @@ func TestFirst(t *testing.T) { func TestForAll(t *testing.T) { runCheckedTest(t, func(t *testing.T) { var result int - Just(1, 2, 3, 4).Filter(func(item interface{}) bool { + Just(1, 2, 3, 4).Filter(func(item any) bool { return item.(int)%2 == 0 - }).ForAll(func(pipe <-chan interface{}) { + }).ForAll(func(pipe <-chan any) { for item := range pipe { result += item.(int) } @@ -168,11 +168,11 @@ func TestForAll(t *testing.T) { func TestGroup(t *testing.T) { runCheckedTest(t, func(t *testing.T) { var groups [][]int - Just(10, 11, 20, 21).Group(func(item interface{}) interface{} { + Just(10, 11, 20, 21).Group(func(item any) any { v := item.(int) return v / 10 - }).ForEach(func(item interface{}) { - v := item.([]interface{}) + }).ForEach(func(item any) { + v := item.([]any) var group []int for _, each := range v { group = append(group, each.(int)) @@ -191,7 +191,7 @@ func TestGroup(t *testing.T) { func TestHead(t *testing.T) { runCheckedTest(t, func(t *testing.T) { var result int - Just(1, 2, 3, 4).Head(2).Reduce(func(pipe <-chan interface{}) (interface{}, error) { + Just(1, 2, 3, 4).Head(2).Reduce(func(pipe <-chan any) (any, error) { for item := range pipe { result += item.(int) } @@ -204,7 +204,7 @@ func TestHead(t *testing.T) { func TestHeadZero(t *testing.T) { runCheckedTest(t, func(t *testing.T) { assert.Panics(t, func() { - Just(1, 2, 3, 4).Head(0).Reduce(func(pipe <-chan interface{}) (interface{}, error) { + Just(1, 2, 3, 4).Head(0).Reduce(func(pipe <-chan any) (any, error) { return nil, nil }) }) @@ -214,7 +214,7 @@ func TestHeadZero(t *testing.T) { func TestHeadMore(t *testing.T) { runCheckedTest(t, func(t *testing.T) { var result int - Just(1, 2, 3, 4).Head(6).Reduce(func(pipe <-chan interface{}) (interface{}, error) { + Just(1, 2, 3, 4).Head(6).Reduce(func(pipe <-chan any) (any, error) { for item := range pipe { result += item.(int) } @@ -245,14 +245,14 @@ func TestMap(t *testing.T) { expect int }{ { - mapper: func(item interface{}) interface{} { + mapper: func(item any) any { v := item.(int) return v * v }, expect: 30, }, { - mapper: func(item interface{}) interface{} { + mapper: func(item any) any { v := item.(int) if v%2 == 0 { return 0 @@ -262,7 +262,7 @@ func TestMap(t *testing.T) { expect: 10, }, { - mapper: func(item interface{}) interface{} { + mapper: func(item any) any { v := item.(int) if v%2 == 0 { panic(v) @@ -283,12 +283,12 @@ func TestMap(t *testing.T) { } else { workers = runtime.NumCPU() } - From(func(source chan<- interface{}) { + From(func(source chan<- any) { for i := 1; i < 5; i++ { source <- i } }).Map(test.mapper, WithWorkers(workers)).Reduce( - func(pipe <-chan interface{}) (interface{}, error) { + func(pipe <-chan any) (any, error) { for item := range pipe { result += item.(int) } @@ -303,8 +303,8 @@ func TestMap(t *testing.T) { func TestMerge(t *testing.T) { runCheckedTest(t, func(t *testing.T) { - Just(1, 2, 3, 4).Merge().ForEach(func(item interface{}) { - assert.ElementsMatch(t, []interface{}{1, 2, 3, 4}, item.([]interface{})) + Just(1, 2, 3, 4).Merge().ForEach(func(item any) { + assert.ElementsMatch(t, []any{1, 2, 3, 4}, item.([]any)) }) }) } @@ -312,7 +312,7 @@ func TestMerge(t *testing.T) { func TestParallelJust(t *testing.T) { runCheckedTest(t, func(t *testing.T) { var count int32 - Just(1, 2, 3).Parallel(func(item interface{}) { + Just(1, 2, 3).Parallel(func(item any) { time.Sleep(time.Millisecond * 100) atomic.AddInt32(&count, int32(item.(int))) }, UnlimitedWorkers()) @@ -322,8 +322,8 @@ func TestParallelJust(t *testing.T) { func TestReverse(t *testing.T) { runCheckedTest(t, func(t *testing.T) { - Just(1, 2, 3, 4).Reverse().Merge().ForEach(func(item interface{}) { - assert.ElementsMatch(t, []interface{}{4, 3, 2, 1}, item.([]interface{})) + Just(1, 2, 3, 4).Reverse().Merge().ForEach(func(item any) { + assert.ElementsMatch(t, []any{4, 3, 2, 1}, item.([]any)) }) }) } @@ -331,9 +331,9 @@ func TestReverse(t *testing.T) { func TestSort(t *testing.T) { runCheckedTest(t, func(t *testing.T) { var prev int - Just(5, 3, 7, 1, 9, 6, 4, 8, 2).Sort(func(a, b interface{}) bool { + Just(5, 3, 7, 1, 9, 6, 4, 8, 2).Sort(func(a, b any) bool { return a.(int) < b.(int) - }).ForEach(func(item interface{}) { + }).ForEach(func(item any) { next := item.(int) assert.True(t, prev < next) prev = next @@ -346,12 +346,12 @@ func TestSplit(t *testing.T) { assert.Panics(t, func() { Just(1, 2, 3, 4, 5, 6, 7, 8, 9, 10).Split(0).Done() }) - var chunks [][]interface{} - Just(1, 2, 3, 4, 5, 6, 7, 8, 9, 10).Split(4).ForEach(func(item interface{}) { - chunk := item.([]interface{}) + var chunks [][]any + Just(1, 2, 3, 4, 5, 6, 7, 8, 9, 10).Split(4).ForEach(func(item any) { + chunk := item.([]any) chunks = append(chunks, chunk) }) - assert.EqualValues(t, [][]interface{}{ + assert.EqualValues(t, [][]any{ {1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10}, @@ -362,7 +362,7 @@ func TestSplit(t *testing.T) { func TestTail(t *testing.T) { runCheckedTest(t, func(t *testing.T) { var result int - Just(1, 2, 3, 4).Tail(2).Reduce(func(pipe <-chan interface{}) (interface{}, error) { + Just(1, 2, 3, 4).Tail(2).Reduce(func(pipe <-chan any) (any, error) { for item := range pipe { result += item.(int) } @@ -375,7 +375,7 @@ func TestTail(t *testing.T) { func TestTailZero(t *testing.T) { runCheckedTest(t, func(t *testing.T) { assert.Panics(t, func() { - Just(1, 2, 3, 4).Tail(0).Reduce(func(pipe <-chan interface{}) (interface{}, error) { + Just(1, 2, 3, 4).Tail(0).Reduce(func(pipe <-chan any) (any, error) { return nil, nil }) }) @@ -385,11 +385,11 @@ func TestTailZero(t *testing.T) { func TestWalk(t *testing.T) { runCheckedTest(t, func(t *testing.T) { var result int - Just(1, 2, 3, 4, 5).Walk(func(item interface{}, pipe chan<- interface{}) { + Just(1, 2, 3, 4, 5).Walk(func(item any, pipe chan<- any) { if item.(int)%2 != 0 { pipe <- item } - }, UnlimitedWorkers()).ForEach(func(item interface{}) { + }, UnlimitedWorkers()).ForEach(func(item any) { result += item.(int) }) assert.Equal(t, 9, result) @@ -398,16 +398,16 @@ func TestWalk(t *testing.T) { func TestStream_AnyMach(t *testing.T) { runCheckedTest(t, func(t *testing.T) { - assetEqual(t, false, Just(1, 2, 3).AnyMach(func(item interface{}) bool { + assetEqual(t, false, Just(1, 2, 3).AnyMach(func(item any) bool { return item.(int) == 4 })) - assetEqual(t, false, Just(1, 2, 3).AnyMach(func(item interface{}) bool { + assetEqual(t, false, Just(1, 2, 3).AnyMach(func(item any) bool { return item.(int) == 0 })) - assetEqual(t, true, Just(1, 2, 3).AnyMach(func(item interface{}) bool { + assetEqual(t, true, Just(1, 2, 3).AnyMach(func(item any) bool { return item.(int) == 2 })) - assetEqual(t, true, Just(1, 2, 3).AnyMach(func(item interface{}) bool { + assetEqual(t, true, Just(1, 2, 3).AnyMach(func(item any) bool { return item.(int) == 2 })) }) @@ -416,17 +416,17 @@ func TestStream_AnyMach(t *testing.T) { func TestStream_AllMach(t *testing.T) { runCheckedTest(t, func(t *testing.T) { assetEqual( - t, true, Just(1, 2, 3).AllMach(func(item interface{}) bool { + t, true, Just(1, 2, 3).AllMach(func(item any) bool { return true }), ) assetEqual( - t, false, Just(1, 2, 3).AllMach(func(item interface{}) bool { + t, false, Just(1, 2, 3).AllMach(func(item any) bool { return false }), ) assetEqual( - t, false, Just(1, 2, 3).AllMach(func(item interface{}) bool { + t, false, Just(1, 2, 3).AllMach(func(item any) bool { return item.(int) == 1 }), ) @@ -436,17 +436,17 @@ func TestStream_AllMach(t *testing.T) { func TestStream_NoneMatch(t *testing.T) { runCheckedTest(t, func(t *testing.T) { assetEqual( - t, true, Just(1, 2, 3).NoneMatch(func(item interface{}) bool { + t, true, Just(1, 2, 3).NoneMatch(func(item any) bool { return false }), ) assetEqual( - t, false, Just(1, 2, 3).NoneMatch(func(item interface{}) bool { + t, false, Just(1, 2, 3).NoneMatch(func(item any) bool { return true }), ) assetEqual( - t, true, Just(1, 2, 3).NoneMatch(func(item interface{}) bool { + t, true, Just(1, 2, 3).NoneMatch(func(item any) bool { return item.(int) == 4 }), ) @@ -455,19 +455,19 @@ func TestStream_NoneMatch(t *testing.T) { func TestConcat(t *testing.T) { runCheckedTest(t, func(t *testing.T) { - a1 := []interface{}{1, 2, 3} - a2 := []interface{}{4, 5, 6} + a1 := []any{1, 2, 3} + a2 := []any{4, 5, 6} s1 := Just(a1...) s2 := Just(a2...) stream := Concat(s1, s2) - var items []interface{} + var items []any for item := range stream.source { items = append(items, item) } sort.Slice(items, func(i, j int) bool { return items[i].(int) < items[j].(int) }) - ints := make([]interface{}, 0) + ints := make([]any, 0) ints = append(ints, a1...) ints = append(ints, a2...) assetEqual(t, ints, items) @@ -479,7 +479,7 @@ func TestStream_Skip(t *testing.T) { assetEqual(t, 3, Just(1, 2, 3, 4).Skip(1).Count()) assetEqual(t, 1, Just(1, 2, 3, 4).Skip(3).Count()) assetEqual(t, 4, Just(1, 2, 3, 4).Skip(0).Count()) - equal(t, Just(1, 2, 3, 4).Skip(3), []interface{}{4}) + equal(t, Just(1, 2, 3, 4).Skip(3), []any{4}) assert.Panics(t, func() { Just(1, 2, 3, 4).Skip(-1) }) @@ -489,27 +489,27 @@ func TestStream_Skip(t *testing.T) { func TestStream_Concat(t *testing.T) { runCheckedTest(t, func(t *testing.T) { stream := Just(1).Concat(Just(2), Just(3)) - var items []interface{} + var items []any for item := range stream.source { items = append(items, item) } sort.Slice(items, func(i, j int) bool { return items[i].(int) < items[j].(int) }) - assetEqual(t, []interface{}{1, 2, 3}, items) + assetEqual(t, []any{1, 2, 3}, items) just := Just(1) - equal(t, just.Concat(just), []interface{}{1}) + equal(t, just.Concat(just), []any{1}) }) } func BenchmarkParallelMapReduce(b *testing.B) { b.ReportAllocs() - mapper := func(v interface{}) interface{} { + mapper := func(v any) any { return v.(int64) * v.(int64) } - reducer := func(input <-chan interface{}) (interface{}, error) { + reducer := func(input <-chan any) (any, error) { var result int64 for v := range input { result += v.(int64) @@ -517,7 +517,7 @@ func BenchmarkParallelMapReduce(b *testing.B) { return result, nil } b.ResetTimer() - From(func(input chan<- interface{}) { + From(func(input chan<- any) { b.RunParallel(func(pb *testing.PB) { for pb.Next() { input <- int64(rand.Int()) @@ -529,10 +529,10 @@ func BenchmarkParallelMapReduce(b *testing.B) { func BenchmarkMapReduce(b *testing.B) { b.ReportAllocs() - mapper := func(v interface{}) interface{} { + mapper := func(v any) any { return v.(int64) * v.(int64) } - reducer := func(input <-chan interface{}) (interface{}, error) { + reducer := func(input <-chan any) (any, error) { var result int64 for v := range input { result += v.(int64) @@ -540,21 +540,21 @@ func BenchmarkMapReduce(b *testing.B) { return result, nil } b.ResetTimer() - From(func(input chan<- interface{}) { + From(func(input chan<- any) { for i := 0; i < b.N; i++ { input <- int64(rand.Int()) } }).Map(mapper).Reduce(reducer) } -func assetEqual(t *testing.T, except, data interface{}) { +func assetEqual(t *testing.T, except, data any) { if !reflect.DeepEqual(except, data) { t.Errorf(" %v, want %v", data, except) } } -func equal(t *testing.T, stream Stream, data []interface{}) { - items := make([]interface{}, 0) +func equal(t *testing.T, stream Stream, data []any) { + items := make([]any, 0) for item := range stream.source { items = append(items, item) } diff --git a/core/fx/timeout.go b/core/fx/timeout.go index 66c61870..a81e2d6e 100644 --- a/core/fx/timeout.go +++ b/core/fx/timeout.go @@ -29,7 +29,7 @@ func DoWithTimeout(fn func() error, timeout time.Duration, opts ...DoOption) err // create channel with buffer size 1 to avoid goroutine leak done := make(chan error, 1) - panicChan := make(chan interface{}, 1) + panicChan := make(chan any, 1) go func() { defer func() { if p := recover(); p != nil { diff --git a/core/hash/consistenthash.go b/core/hash/consistenthash.go index b805c8cc..896ad071 100644 --- a/core/hash/consistenthash.go +++ b/core/hash/consistenthash.go @@ -26,7 +26,7 @@ type ( hashFunc Func replicas int keys []uint64 - ring map[uint64][]interface{} + ring map[uint64][]any nodes map[string]lang.PlaceholderType lock sync.RWMutex } @@ -50,21 +50,21 @@ func NewCustomConsistentHash(replicas int, fn Func) *ConsistentHash { return &ConsistentHash{ hashFunc: fn, replicas: replicas, - ring: make(map[uint64][]interface{}), + ring: make(map[uint64][]any), nodes: make(map[string]lang.PlaceholderType), } } // Add adds the node with the number of h.replicas, // the later call will overwrite the replicas of the former calls. -func (h *ConsistentHash) Add(node interface{}) { +func (h *ConsistentHash) Add(node any) { h.AddWithReplicas(node, h.replicas) } // AddWithReplicas adds the node with the number of replicas, // replicas will be truncated to h.replicas if it's larger than h.replicas, // the later call will overwrite the replicas of the former calls. -func (h *ConsistentHash) AddWithReplicas(node interface{}, replicas int) { +func (h *ConsistentHash) AddWithReplicas(node any, replicas int) { h.Remove(node) if replicas > h.replicas { @@ -89,7 +89,7 @@ func (h *ConsistentHash) AddWithReplicas(node interface{}, replicas int) { // AddWithWeight adds the node with weight, the weight can be 1 to 100, indicates the percent, // the later call will overwrite the replicas of the former calls. -func (h *ConsistentHash) AddWithWeight(node interface{}, weight int) { +func (h *ConsistentHash) AddWithWeight(node any, weight int) { // don't need to make sure weight not larger than TopWeight, // because AddWithReplicas makes sure replicas cannot be larger than h.replicas replicas := h.replicas * weight / TopWeight @@ -97,7 +97,7 @@ func (h *ConsistentHash) AddWithWeight(node interface{}, weight int) { } // Get returns the corresponding node from h base on the given v. -func (h *ConsistentHash) Get(v interface{}) (interface{}, bool) { +func (h *ConsistentHash) Get(v any) (any, bool) { h.lock.RLock() defer h.lock.RUnlock() @@ -124,7 +124,7 @@ func (h *ConsistentHash) Get(v interface{}) (interface{}, bool) { } // Remove removes the given node from h. -func (h *ConsistentHash) Remove(node interface{}) { +func (h *ConsistentHash) Remove(node any) { nodeRepr := repr(node) h.lock.Lock() @@ -177,10 +177,10 @@ func (h *ConsistentHash) removeNode(nodeRepr string) { delete(h.nodes, nodeRepr) } -func innerRepr(node interface{}) string { +func innerRepr(node any) string { return fmt.Sprintf("%d:%v", prime, node) } -func repr(node interface{}) string { +func repr(node any) string { return lang.Repr(node) } diff --git a/core/hash/consistenthash_test.go b/core/hash/consistenthash_test.go index 749dff06..329f2c45 100644 --- a/core/hash/consistenthash_test.go +++ b/core/hash/consistenthash_test.go @@ -42,7 +42,7 @@ func TestConsistentHash(t *testing.T) { keys[key.(string)]++ } - mi := make(map[interface{}]int, len(keys)) + mi := make(map[any]int, len(keys)) for k, v := range keys { mi[k] = v } diff --git a/core/iox/bufferpool.go b/core/iox/bufferpool.go index 9304a34e..d2546c23 100644 --- a/core/iox/bufferpool.go +++ b/core/iox/bufferpool.go @@ -16,7 +16,7 @@ func NewBufferPool(capability int) *BufferPool { return &BufferPool{ capability: capability, pool: &sync.Pool{ - New: func() interface{} { + New: func() any { return new(bytes.Buffer) }, }, diff --git a/core/jsonx/json.go b/core/jsonx/json.go index abe21340..1b522e55 100644 --- a/core/jsonx/json.go +++ b/core/jsonx/json.go @@ -9,12 +9,12 @@ import ( ) // Marshal marshals v into json bytes. -func Marshal(v interface{}) ([]byte, error) { +func Marshal(v any) ([]byte, error) { return json.Marshal(v) } // MarshalToString marshals v into a string. -func MarshalToString(v interface{}) (string, error) { +func MarshalToString(v any) (string, error) { data, err := Marshal(v) if err != nil { return "", err @@ -24,7 +24,7 @@ func MarshalToString(v interface{}) (string, error) { } // Unmarshal unmarshals data bytes into v. -func Unmarshal(data []byte, v interface{}) error { +func Unmarshal(data []byte, v any) error { decoder := json.NewDecoder(bytes.NewReader(data)) if err := unmarshalUseNumber(decoder, v); err != nil { return formatError(string(data), err) @@ -34,7 +34,7 @@ func Unmarshal(data []byte, v interface{}) error { } // UnmarshalFromString unmarshals v from str. -func UnmarshalFromString(str string, v interface{}) error { +func UnmarshalFromString(str string, v any) error { decoder := json.NewDecoder(strings.NewReader(str)) if err := unmarshalUseNumber(decoder, v); err != nil { return formatError(str, err) @@ -44,7 +44,7 @@ func UnmarshalFromString(str string, v interface{}) error { } // UnmarshalFromReader unmarshals v from reader. -func UnmarshalFromReader(reader io.Reader, v interface{}) error { +func UnmarshalFromReader(reader io.Reader, v any) error { var buf strings.Builder teeReader := io.TeeReader(reader, &buf) decoder := json.NewDecoder(teeReader) @@ -55,7 +55,7 @@ func UnmarshalFromReader(reader io.Reader, v interface{}) error { return nil } -func unmarshalUseNumber(decoder *json.Decoder, v interface{}) error { +func unmarshalUseNumber(decoder *json.Decoder, v any) error { decoder.UseNumber() return decoder.Decode(v) } diff --git a/core/lang/lang.go b/core/lang/lang.go index 6ca50973..7a04728a 100644 --- a/core/lang/lang.go +++ b/core/lang/lang.go @@ -11,13 +11,13 @@ var Placeholder PlaceholderType type ( // AnyType can be used to hold any type. - AnyType = interface{} + AnyType = any // PlaceholderType represents a placeholder type. PlaceholderType = struct{} ) // Repr returns the string representation of v. -func Repr(v interface{}) string { +func Repr(v any) string { if v == nil { return "" } diff --git a/core/lang/lang_test.go b/core/lang/lang_test.go index 2c28a5e0..a1ebdc5b 100644 --- a/core/lang/lang_test.go +++ b/core/lang/lang_test.go @@ -23,7 +23,7 @@ func TestRepr(t *testing.T) { u64 uint64 = 8 ) tests := []struct { - v interface{} + v any expect string }{ { diff --git a/core/logc/logs.go b/core/logc/logs.go index ec383e8d..ff413dcd 100644 --- a/core/logc/logs.go +++ b/core/logc/logs.go @@ -28,18 +28,18 @@ func Close() error { } // Error writes v into error log. -func Error(ctx context.Context, v ...interface{}) { +func Error(ctx context.Context, v ...any) { getLogger(ctx).Error(v...) } // Errorf writes v with format into error log. -func Errorf(ctx context.Context, format string, v ...interface{}) { +func Errorf(ctx context.Context, format string, v ...any) { getLogger(ctx).Errorf(fmt.Errorf(format, v...).Error()) } // Errorv writes v into error log with json content. // No call stack attached, because not elegant to pack the messages. -func Errorv(ctx context.Context, v interface{}) { +func Errorv(ctx context.Context, v any) { getLogger(ctx).Errorv(v) } @@ -49,22 +49,22 @@ func Errorw(ctx context.Context, msg string, fields ...LogField) { } // Field returns a LogField for the given key and value. -func Field(key string, value interface{}) LogField { +func Field(key string, value any) LogField { return logx.Field(key, value) } // Info writes v into access log. -func Info(ctx context.Context, v ...interface{}) { +func Info(ctx context.Context, v ...any) { getLogger(ctx).Info(v...) } // Infof writes v with format into access log. -func Infof(ctx context.Context, format string, v ...interface{}) { +func Infof(ctx context.Context, format string, v ...any) { getLogger(ctx).Infof(format, v...) } // Infov writes v into access log with json content. -func Infov(ctx context.Context, v interface{}) { +func Infov(ctx context.Context, v any) { getLogger(ctx).Infov(v) } @@ -97,17 +97,17 @@ func SetUp(c LogConf) error { } // Slow writes v into slow log. -func Slow(ctx context.Context, v ...interface{}) { +func Slow(ctx context.Context, v ...any) { getLogger(ctx).Slow(v...) } // Slowf writes v with format into slow log. -func Slowf(ctx context.Context, format string, v ...interface{}) { +func Slowf(ctx context.Context, format string, v ...any) { getLogger(ctx).Slowf(format, v...) } // Slowv writes v into slow log with json content. -func Slowv(ctx context.Context, v interface{}) { +func Slowv(ctx context.Context, v any) { getLogger(ctx).Slowv(v) } diff --git a/core/logc/logs_test.go b/core/logc/logs_test.go index 14647fa9..0e2f93b0 100644 --- a/core/logc/logs_test.go +++ b/core/logc/logs_test.go @@ -26,7 +26,7 @@ func TestAddGlobalFields(t *testing.T) { AddGlobalFields(Field("a", "1"), Field("b", "2")) AddGlobalFields(Field("c", "3")) Info(context.Background(), "world") - var m map[string]interface{} + var m map[string]any assert.NoError(t, json.Unmarshal(buf.Bytes(), &m)) assert.Equal(t, "1", m["a"]) assert.Equal(t, "2", m["b"]) diff --git a/core/logx/fields_test.go b/core/logx/fields_test.go index 65c87b5e..c0727eb5 100644 --- a/core/logx/fields_test.go +++ b/core/logx/fields_test.go @@ -25,7 +25,7 @@ func TestAddGlobalFields(t *testing.T) { AddGlobalFields(Field("a", "1"), Field("b", "2")) AddGlobalFields(Field("c", "3")) Info("world") - var m map[string]interface{} + var m map[string]any assert.NoError(t, json.Unmarshal(buf.Bytes(), &m)) assert.Equal(t, "1", m["a"]) assert.Equal(t, "2", m["b"]) diff --git a/core/logx/lesslogger.go b/core/logx/lesslogger.go index 94200ca6..35ca2051 100644 --- a/core/logx/lesslogger.go +++ b/core/logx/lesslogger.go @@ -13,14 +13,14 @@ func NewLessLogger(milliseconds int) *LessLogger { } // Error logs v into error log or discard it if more than once in the given duration. -func (logger *LessLogger) Error(v ...interface{}) { +func (logger *LessLogger) Error(v ...any) { logger.logOrDiscard(func() { Error(v...) }) } // Errorf logs v with format into error log or discard it if more than once in the given duration. -func (logger *LessLogger) Errorf(format string, v ...interface{}) { +func (logger *LessLogger) Errorf(format string, v ...any) { logger.logOrDiscard(func() { Errorf(format, v...) }) diff --git a/core/logx/logger.go b/core/logx/logger.go index a9ea0253..f9dd4a3c 100644 --- a/core/logx/logger.go +++ b/core/logx/logger.go @@ -8,35 +8,35 @@ import ( // A Logger represents a logger. type Logger interface { // Debug logs a message at info level. - Debug(...interface{}) + Debug(...any) // Debugf logs a message at info level. - Debugf(string, ...interface{}) + Debugf(string, ...any) // Debugv logs a message at info level. - Debugv(interface{}) + Debugv(any) // Debugw logs a message at info level. Debugw(string, ...LogField) // Error logs a message at error level. - Error(...interface{}) + Error(...any) // Errorf logs a message at error level. - Errorf(string, ...interface{}) + Errorf(string, ...any) // Errorv logs a message at error level. - Errorv(interface{}) + Errorv(any) // Errorw logs a message at error level. Errorw(string, ...LogField) // Info logs a message at info level. - Info(...interface{}) + Info(...any) // Infof logs a message at info level. - Infof(string, ...interface{}) + Infof(string, ...any) // Infov logs a message at info level. - Infov(interface{}) + Infov(any) // Infow logs a message at info level. Infow(string, ...LogField) // Slow logs a message at slow level. - Slow(...interface{}) + Slow(...any) // Slowf logs a message at slow level. - Slowf(string, ...interface{}) + Slowf(string, ...any) // Slowv logs a message at slow level. - Slowv(interface{}) + Slowv(any) // Sloww logs a message at slow level. Sloww(string, ...LogField) // WithCallerSkip returns a new logger with the given caller skip. diff --git a/core/logx/logs.go b/core/logx/logs.go index 734629a2..1f5e120b 100644 --- a/core/logx/logs.go +++ b/core/logx/logs.go @@ -34,13 +34,13 @@ type ( // LogField is a key-value pair that will be added to the log entry. LogField struct { Key string - Value interface{} + Value any } // LogOption defines the method to customize the logging. LogOption func(options *logOptions) - logEntry map[string]interface{} + logEntry map[string]any logOptions struct { gzipEnabled bool @@ -67,17 +67,17 @@ func Close() error { } // Debug writes v into access log. -func Debug(v ...interface{}) { +func Debug(v ...any) { writeDebug(fmt.Sprint(v...)) } // Debugf writes v with format into access log. -func Debugf(format string, v ...interface{}) { +func Debugf(format string, v ...any) { writeDebug(fmt.Sprintf(format, v...)) } // Debugv writes v into access log with json content. -func Debugv(v interface{}) { +func Debugv(v any) { writeDebug(v) } @@ -98,30 +98,30 @@ func DisableStat() { } // Error writes v into error log. -func Error(v ...interface{}) { +func Error(v ...any) { writeError(fmt.Sprint(v...)) } // Errorf writes v with format into error log. -func Errorf(format string, v ...interface{}) { +func Errorf(format string, v ...any) { writeError(fmt.Errorf(format, v...).Error()) } // ErrorStack writes v along with call stack into error log. -func ErrorStack(v ...interface{}) { +func ErrorStack(v ...any) { // there is newline in stack string writeStack(fmt.Sprint(v...)) } // ErrorStackf writes v along with call stack in format into error log. -func ErrorStackf(format string, v ...interface{}) { +func ErrorStackf(format string, v ...any) { // there is newline in stack string writeStack(fmt.Sprintf(format, v...)) } // Errorv writes v into error log with json content. // No call stack attached, because not elegant to pack the messages. -func Errorv(v interface{}) { +func Errorv(v any) { writeError(v) } @@ -131,7 +131,7 @@ func Errorw(msg string, fields ...LogField) { } // Field returns a LogField for the given key and value. -func Field(key string, value interface{}) LogField { +func Field(key string, value any) LogField { switch val := value.(type) { case error: return LogField{Key: key, Value: val.Error()} @@ -169,17 +169,17 @@ func Field(key string, value interface{}) LogField { } // Info writes v into access log. -func Info(v ...interface{}) { +func Info(v ...any) { writeInfo(fmt.Sprint(v...)) } // Infof writes v with format into access log. -func Infof(format string, v ...interface{}) { +func Infof(format string, v ...any) { writeInfo(fmt.Sprintf(format, v...)) } // Infov writes v into access log with json content. -func Infov(v interface{}) { +func Infov(v any) { writeInfo(v) } @@ -263,27 +263,27 @@ func SetUp(c LogConf) (err error) { } // Severe writes v into severe log. -func Severe(v ...interface{}) { +func Severe(v ...any) { writeSevere(fmt.Sprint(v...)) } // Severef writes v with format into severe log. -func Severef(format string, v ...interface{}) { +func Severef(format string, v ...any) { writeSevere(fmt.Sprintf(format, v...)) } // Slow writes v into slow log. -func Slow(v ...interface{}) { +func Slow(v ...any) { writeSlow(fmt.Sprint(v...)) } // Slowf writes v with format into slow log. -func Slowf(format string, v ...interface{}) { +func Slowf(format string, v ...any) { writeSlow(fmt.Sprintf(format, v...)) } // Slowv writes v into slow log with json content. -func Slowv(v interface{}) { +func Slowv(v any) { writeSlow(v) } @@ -293,12 +293,12 @@ func Sloww(msg string, fields ...LogField) { } // Stat writes v into stat log. -func Stat(v ...interface{}) { +func Stat(v ...any) { writeStat(fmt.Sprint(v...)) } // Statf writes v with format into stat log. -func Statf(format string, v ...interface{}) { +func Statf(format string, v ...any) { writeStat(fmt.Sprintf(format, v...)) } @@ -422,19 +422,19 @@ func shallLogStat() bool { return atomic.LoadUint32(&disableStat) == 0 } -func writeDebug(val interface{}, fields ...LogField) { +func writeDebug(val any, fields ...LogField) { if shallLog(DebugLevel) { getWriter().Debug(val, addCaller(fields...)...) } } -func writeError(val interface{}, fields ...LogField) { +func writeError(val any, fields ...LogField) { if shallLog(ErrorLevel) { getWriter().Error(val, addCaller(fields...)...) } } -func writeInfo(val interface{}, fields ...LogField) { +func writeInfo(val any, fields ...LogField) { if shallLog(InfoLevel) { getWriter().Info(val, addCaller(fields...)...) } @@ -446,7 +446,7 @@ func writeSevere(msg string) { } } -func writeSlow(val interface{}, fields ...LogField) { +func writeSlow(val any, fields ...LogField) { if shallLog(ErrorLevel) { getWriter().Slow(val, addCaller(fields...)...) } diff --git a/core/logx/logs_test.go b/core/logx/logs_test.go index e3938866..541da29c 100644 --- a/core/logx/logs_test.go +++ b/core/logx/logs_test.go @@ -29,49 +29,49 @@ type mockWriter struct { builder strings.Builder } -func (mw *mockWriter) Alert(v interface{}) { +func (mw *mockWriter) Alert(v any) { mw.lock.Lock() defer mw.lock.Unlock() output(&mw.builder, levelAlert, v) } -func (mw *mockWriter) Debug(v interface{}, fields ...LogField) { +func (mw *mockWriter) Debug(v any, fields ...LogField) { mw.lock.Lock() defer mw.lock.Unlock() output(&mw.builder, levelDebug, v, fields...) } -func (mw *mockWriter) Error(v interface{}, fields ...LogField) { +func (mw *mockWriter) Error(v any, fields ...LogField) { mw.lock.Lock() defer mw.lock.Unlock() output(&mw.builder, levelError, v, fields...) } -func (mw *mockWriter) Info(v interface{}, fields ...LogField) { +func (mw *mockWriter) Info(v any, fields ...LogField) { mw.lock.Lock() defer mw.lock.Unlock() output(&mw.builder, levelInfo, v, fields...) } -func (mw *mockWriter) Severe(v interface{}) { +func (mw *mockWriter) Severe(v any) { mw.lock.Lock() defer mw.lock.Unlock() output(&mw.builder, levelSevere, v) } -func (mw *mockWriter) Slow(v interface{}, fields ...LogField) { +func (mw *mockWriter) Slow(v any, fields ...LogField) { mw.lock.Lock() defer mw.lock.Unlock() output(&mw.builder, levelSlow, v, fields...) } -func (mw *mockWriter) Stack(v interface{}) { +func (mw *mockWriter) Stack(v any) { mw.lock.Lock() defer mw.lock.Unlock() output(&mw.builder, levelError, v) } -func (mw *mockWriter) Stat(v interface{}, fields ...LogField) { +func (mw *mockWriter) Stat(v any, fields ...LogField) { mw.lock.Lock() defer mw.lock.Unlock() output(&mw.builder, levelStat, v, fields...) @@ -103,41 +103,41 @@ func TestField(t *testing.T) { tests := []struct { name string f LogField - want map[string]interface{} + want map[string]any }{ { name: "error", f: Field("foo", errors.New("bar")), - want: map[string]interface{}{ + want: map[string]any{ "foo": "bar", }, }, { name: "errors", f: Field("foo", []error{errors.New("bar"), errors.New("baz")}), - want: map[string]interface{}{ - "foo": []interface{}{"bar", "baz"}, + want: map[string]any{ + "foo": []any{"bar", "baz"}, }, }, { name: "strings", f: Field("foo", []string{"bar", "baz"}), - want: map[string]interface{}{ - "foo": []interface{}{"bar", "baz"}, + want: map[string]any{ + "foo": []any{"bar", "baz"}, }, }, { name: "duration", f: Field("foo", time.Second), - want: map[string]interface{}{ + want: map[string]any{ "foo": "1s", }, }, { name: "durations", f: Field("foo", []time.Duration{time.Second, 2 * time.Second}), - want: map[string]interface{}{ - "foo": []interface{}{"1s", "2s"}, + want: map[string]any{ + "foo": []any{"1s", "2s"}, }, }, { @@ -146,22 +146,22 @@ func TestField(t *testing.T) { time.Date(2020, time.January, 1, 0, 0, 0, 0, time.UTC), time.Date(2020, time.January, 2, 0, 0, 0, 0, time.UTC), }), - want: map[string]interface{}{ - "foo": []interface{}{"2020-01-01 00:00:00 +0000 UTC", "2020-01-02 00:00:00 +0000 UTC"}, + want: map[string]any{ + "foo": []any{"2020-01-01 00:00:00 +0000 UTC", "2020-01-02 00:00:00 +0000 UTC"}, }, }, { name: "stringer", f: Field("foo", ValStringer{val: "bar"}), - want: map[string]interface{}{ + want: map[string]any{ "foo": "bar", }, }, { name: "stringers", f: Field("foo", []fmt.Stringer{ValStringer{val: "bar"}, ValStringer{val: "baz"}}), - want: map[string]interface{}{ - "foo": []interface{}{"bar", "baz"}, + want: map[string]any{ + "foo": []any{"bar", "baz"}, }, }, } @@ -213,7 +213,7 @@ func TestStructedLogAlert(t *testing.T) { old := writer.Swap(w) defer writer.Store(old) - doTestStructedLog(t, levelAlert, w, func(v ...interface{}) { + doTestStructedLog(t, levelAlert, w, func(v ...any) { Alert(fmt.Sprint(v...)) }) } @@ -223,7 +223,7 @@ func TestStructedLogDebug(t *testing.T) { old := writer.Swap(w) defer writer.Store(old) - doTestStructedLog(t, levelDebug, w, func(v ...interface{}) { + doTestStructedLog(t, levelDebug, w, func(v ...any) { Debug(v...) }) } @@ -233,7 +233,7 @@ func TestStructedLogDebugf(t *testing.T) { old := writer.Swap(w) defer writer.Store(old) - doTestStructedLog(t, levelDebug, w, func(v ...interface{}) { + doTestStructedLog(t, levelDebug, w, func(v ...any) { Debugf(fmt.Sprint(v...)) }) } @@ -243,7 +243,7 @@ func TestStructedLogDebugv(t *testing.T) { old := writer.Swap(w) defer writer.Store(old) - doTestStructedLog(t, levelDebug, w, func(v ...interface{}) { + doTestStructedLog(t, levelDebug, w, func(v ...any) { Debugv(fmt.Sprint(v...)) }) } @@ -253,7 +253,7 @@ func TestStructedLogDebugw(t *testing.T) { old := writer.Swap(w) defer writer.Store(old) - doTestStructedLog(t, levelDebug, w, func(v ...interface{}) { + doTestStructedLog(t, levelDebug, w, func(v ...any) { Debugw(fmt.Sprint(v...), Field("foo", time.Second)) }) } @@ -263,7 +263,7 @@ func TestStructedLogError(t *testing.T) { old := writer.Swap(w) defer writer.Store(old) - doTestStructedLog(t, levelError, w, func(v ...interface{}) { + doTestStructedLog(t, levelError, w, func(v ...any) { Error(v...) }) } @@ -273,7 +273,7 @@ func TestStructedLogErrorf(t *testing.T) { old := writer.Swap(w) defer writer.Store(old) - doTestStructedLog(t, levelError, w, func(v ...interface{}) { + doTestStructedLog(t, levelError, w, func(v ...any) { Errorf("%s", fmt.Sprint(v...)) }) } @@ -283,7 +283,7 @@ func TestStructedLogErrorv(t *testing.T) { old := writer.Swap(w) defer writer.Store(old) - doTestStructedLog(t, levelError, w, func(v ...interface{}) { + doTestStructedLog(t, levelError, w, func(v ...any) { Errorv(fmt.Sprint(v...)) }) } @@ -293,7 +293,7 @@ func TestStructedLogErrorw(t *testing.T) { old := writer.Swap(w) defer writer.Store(old) - doTestStructedLog(t, levelError, w, func(v ...interface{}) { + doTestStructedLog(t, levelError, w, func(v ...any) { Errorw(fmt.Sprint(v...), Field("foo", "bar")) }) } @@ -303,7 +303,7 @@ func TestStructedLogInfo(t *testing.T) { old := writer.Swap(w) defer writer.Store(old) - doTestStructedLog(t, levelInfo, w, func(v ...interface{}) { + doTestStructedLog(t, levelInfo, w, func(v ...any) { Info(v...) }) } @@ -313,7 +313,7 @@ func TestStructedLogInfof(t *testing.T) { old := writer.Swap(w) defer writer.Store(old) - doTestStructedLog(t, levelInfo, w, func(v ...interface{}) { + doTestStructedLog(t, levelInfo, w, func(v ...any) { Infof("%s", fmt.Sprint(v...)) }) } @@ -323,7 +323,7 @@ func TestStructedLogInfov(t *testing.T) { old := writer.Swap(w) defer writer.Store(old) - doTestStructedLog(t, levelInfo, w, func(v ...interface{}) { + doTestStructedLog(t, levelInfo, w, func(v ...any) { Infov(fmt.Sprint(v...)) }) } @@ -333,7 +333,7 @@ func TestStructedLogInfow(t *testing.T) { old := writer.Swap(w) defer writer.Store(old) - doTestStructedLog(t, levelInfo, w, func(v ...interface{}) { + doTestStructedLog(t, levelInfo, w, func(v ...any) { Infow(fmt.Sprint(v...), Field("foo", "bar")) }) } @@ -343,7 +343,7 @@ func TestStructedLogInfoConsoleAny(t *testing.T) { old := writer.Swap(w) defer writer.Store(old) - doTestStructedLogConsole(t, w, func(v ...interface{}) { + doTestStructedLogConsole(t, w, func(v ...any) { old := atomic.LoadUint32(&encoding) atomic.StoreUint32(&encoding, plainEncodingType) defer func() { @@ -359,7 +359,7 @@ func TestStructedLogInfoConsoleAnyString(t *testing.T) { old := writer.Swap(w) defer writer.Store(old) - doTestStructedLogConsole(t, w, func(v ...interface{}) { + doTestStructedLogConsole(t, w, func(v ...any) { old := atomic.LoadUint32(&encoding) atomic.StoreUint32(&encoding, plainEncodingType) defer func() { @@ -375,7 +375,7 @@ func TestStructedLogInfoConsoleAnyError(t *testing.T) { old := writer.Swap(w) defer writer.Store(old) - doTestStructedLogConsole(t, w, func(v ...interface{}) { + doTestStructedLogConsole(t, w, func(v ...any) { old := atomic.LoadUint32(&encoding) atomic.StoreUint32(&encoding, plainEncodingType) defer func() { @@ -391,7 +391,7 @@ func TestStructedLogInfoConsoleAnyStringer(t *testing.T) { old := writer.Swap(w) defer writer.Store(old) - doTestStructedLogConsole(t, w, func(v ...interface{}) { + doTestStructedLogConsole(t, w, func(v ...any) { old := atomic.LoadUint32(&encoding) atomic.StoreUint32(&encoding, plainEncodingType) defer func() { @@ -409,7 +409,7 @@ func TestStructedLogInfoConsoleText(t *testing.T) { old := writer.Swap(w) defer writer.Store(old) - doTestStructedLogConsole(t, w, func(v ...interface{}) { + doTestStructedLogConsole(t, w, func(v ...any) { old := atomic.LoadUint32(&encoding) atomic.StoreUint32(&encoding, plainEncodingType) defer func() { @@ -425,7 +425,7 @@ func TestStructedLogSlow(t *testing.T) { old := writer.Swap(w) defer writer.Store(old) - doTestStructedLog(t, levelSlow, w, func(v ...interface{}) { + doTestStructedLog(t, levelSlow, w, func(v ...any) { Slow(v...) }) } @@ -435,7 +435,7 @@ func TestStructedLogSlowf(t *testing.T) { old := writer.Swap(w) defer writer.Store(old) - doTestStructedLog(t, levelSlow, w, func(v ...interface{}) { + doTestStructedLog(t, levelSlow, w, func(v ...any) { Slowf(fmt.Sprint(v...)) }) } @@ -445,7 +445,7 @@ func TestStructedLogSlowv(t *testing.T) { old := writer.Swap(w) defer writer.Store(old) - doTestStructedLog(t, levelSlow, w, func(v ...interface{}) { + doTestStructedLog(t, levelSlow, w, func(v ...any) { Slowv(fmt.Sprint(v...)) }) } @@ -455,7 +455,7 @@ func TestStructedLogSloww(t *testing.T) { old := writer.Swap(w) defer writer.Store(old) - doTestStructedLog(t, levelSlow, w, func(v ...interface{}) { + doTestStructedLog(t, levelSlow, w, func(v ...any) { Sloww(fmt.Sprint(v...), Field("foo", time.Second)) }) } @@ -465,7 +465,7 @@ func TestStructedLogStat(t *testing.T) { old := writer.Swap(w) defer writer.Store(old) - doTestStructedLog(t, levelStat, w, func(v ...interface{}) { + doTestStructedLog(t, levelStat, w, func(v ...any) { Stat(v...) }) } @@ -475,7 +475,7 @@ func TestStructedLogStatf(t *testing.T) { old := writer.Swap(w) defer writer.Store(old) - doTestStructedLog(t, levelStat, w, func(v ...interface{}) { + doTestStructedLog(t, levelStat, w, func(v ...any) { Statf(fmt.Sprint(v...)) }) } @@ -485,7 +485,7 @@ func TestStructedLogSevere(t *testing.T) { old := writer.Swap(w) defer writer.Store(old) - doTestStructedLog(t, levelSevere, w, func(v ...interface{}) { + doTestStructedLog(t, levelSevere, w, func(v ...any) { Severe(v...) }) } @@ -495,7 +495,7 @@ func TestStructedLogSeveref(t *testing.T) { old := writer.Swap(w) defer writer.Store(old) - doTestStructedLog(t, levelSevere, w, func(v ...interface{}) { + doTestStructedLog(t, levelSevere, w, func(v ...any) { Severef(fmt.Sprint(v...)) }) } @@ -507,7 +507,7 @@ func TestStructedLogWithDuration(t *testing.T) { defer writer.Store(old) WithDuration(time.Second).Info(message) - var entry map[string]interface{} + var entry map[string]any if err := json.Unmarshal([]byte(w.String()), &entry); err != nil { t.Error(err) } @@ -767,11 +767,11 @@ func put(b []byte) { } } -func doTestStructedLog(t *testing.T, level string, w *mockWriter, write func(...interface{})) { +func doTestStructedLog(t *testing.T, level string, w *mockWriter, write func(...any)) { const message = "hello there" write(message) - var entry map[string]interface{} + var entry map[string]any if err := json.Unmarshal([]byte(w.String()), &entry); err != nil { t.Error(err) } @@ -782,7 +782,7 @@ func doTestStructedLog(t *testing.T, level string, w *mockWriter, write func(... assert.True(t, strings.Contains(val.(string), message)) } -func doTestStructedLogConsole(t *testing.T, w *mockWriter, write func(...interface{})) { +func doTestStructedLogConsole(t *testing.T, w *mockWriter, write func(...any)) { const message = "hello there" write(message) assert.True(t, strings.Contains(w.String(), message)) @@ -822,8 +822,8 @@ func (v ValStringer) String() string { return v.val } -func validateFields(t *testing.T, content string, fields map[string]interface{}) { - var m map[string]interface{} +func validateFields(t *testing.T, content string, fields map[string]any) { + var m map[string]any if err := json.Unmarshal([]byte(content), &m); err != nil { t.Error(err) } diff --git a/core/logx/readme-cn.md b/core/logx/readme-cn.md index c8087b92..4f3d21c2 100644 --- a/core/logx/readme-cn.md +++ b/core/logx/readme-cn.md @@ -52,27 +52,27 @@ type LogConf struct { ```go type Logger interface { // Error logs a message at error level. - Error(...interface{}) + Error(...any) // Errorf logs a message at error level. - Errorf(string, ...interface{}) + Errorf(string, ...any) // Errorv logs a message at error level. - Errorv(interface{}) + Errorv(any) // Errorw logs a message at error level. Errorw(string, ...LogField) // Info logs a message at info level. - Info(...interface{}) + Info(...any) // Infof logs a message at info level. - Infof(string, ...interface{}) + Infof(string, ...any) // Infov logs a message at info level. - Infov(interface{}) + Infov(any) // Infow logs a message at info level. Infow(string, ...LogField) // Slow logs a message at slow level. - Slow(...interface{}) + Slow(...any) // Slowf logs a message at slow level. - Slowf(string, ...interface{}) + Slowf(string, ...any) // Slowv logs a message at slow level. - Slowv(interface{}) + Slowv(any) // Sloww logs a message at slow level. Sloww(string, ...LogField) // WithContext returns a new logger with the given context. @@ -165,7 +165,7 @@ func NewSensitiveLogger(writer logx.Writer) *SensitiveLogger { } } -func (l *SensitiveLogger) Info(msg interface{}, fields ...logx.LogField) { +func (l *SensitiveLogger) Info(msg any, fields ...logx.LogField) { if m, ok := msg.(Message); ok { l.Writer.Info(Message{ Name: m.Name, diff --git a/core/logx/readme.md b/core/logx/readme.md index 5949cad8..1e3bdfb2 100644 --- a/core/logx/readme.md +++ b/core/logx/readme.md @@ -51,27 +51,27 @@ type LogConf struct { ```go type Logger interface { // Error logs a message at error level. - Error(...interface{}) + Error(...any) // Errorf logs a message at error level. - Errorf(string, ...interface{}) + Errorf(string, ...any) // Errorv logs a message at error level. - Errorv(interface{}) + Errorv(any) // Errorw logs a message at error level. Errorw(string, ...LogField) // Info logs a message at info level. - Info(...interface{}) + Info(...any) // Infof logs a message at info level. - Infof(string, ...interface{}) + Infof(string, ...any) // Infov logs a message at info level. - Infov(interface{}) + Infov(any) // Infow logs a message at info level. Infow(string, ...LogField) // Slow logs a message at slow level. - Slow(...interface{}) + Slow(...any) // Slowf logs a message at slow level. - Slowf(string, ...interface{}) + Slowf(string, ...any) // Slowv logs a message at slow level. - Slowv(interface{}) + Slowv(any) // Sloww logs a message at slow level. Sloww(string, ...LogField) // WithContext returns a new logger with the given context. @@ -164,7 +164,7 @@ func NewSensitiveLogger(writer logx.Writer) *SensitiveLogger { } } -func (l *SensitiveLogger) Info(msg interface{}, fields ...logx.LogField) { +func (l *SensitiveLogger) Info(msg any, fields ...logx.LogField) { if m, ok := msg.(Message); ok { l.Writer.Info(Message{ Name: m.Name, diff --git a/core/logx/richlogger.go b/core/logx/richlogger.go index bacceb1b..6f2a826d 100644 --- a/core/logx/richlogger.go +++ b/core/logx/richlogger.go @@ -40,15 +40,15 @@ type richLogger struct { fields []LogField } -func (l *richLogger) Debug(v ...interface{}) { +func (l *richLogger) Debug(v ...any) { l.debug(fmt.Sprint(v...)) } -func (l *richLogger) Debugf(format string, v ...interface{}) { +func (l *richLogger) Debugf(format string, v ...any) { l.debug(fmt.Sprintf(format, v...)) } -func (l *richLogger) Debugv(v interface{}) { +func (l *richLogger) Debugv(v any) { l.debug(v) } @@ -56,15 +56,15 @@ func (l *richLogger) Debugw(msg string, fields ...LogField) { l.debug(msg, fields...) } -func (l *richLogger) Error(v ...interface{}) { +func (l *richLogger) Error(v ...any) { l.err(fmt.Sprint(v...)) } -func (l *richLogger) Errorf(format string, v ...interface{}) { +func (l *richLogger) Errorf(format string, v ...any) { l.err(fmt.Sprintf(format, v...)) } -func (l *richLogger) Errorv(v interface{}) { +func (l *richLogger) Errorv(v any) { l.err(fmt.Sprint(v)) } @@ -72,15 +72,15 @@ func (l *richLogger) Errorw(msg string, fields ...LogField) { l.err(msg, fields...) } -func (l *richLogger) Info(v ...interface{}) { +func (l *richLogger) Info(v ...any) { l.info(fmt.Sprint(v...)) } -func (l *richLogger) Infof(format string, v ...interface{}) { +func (l *richLogger) Infof(format string, v ...any) { l.info(fmt.Sprintf(format, v...)) } -func (l *richLogger) Infov(v interface{}) { +func (l *richLogger) Infov(v any) { l.info(v) } @@ -88,15 +88,15 @@ func (l *richLogger) Infow(msg string, fields ...LogField) { l.info(msg, fields...) } -func (l *richLogger) Slow(v ...interface{}) { +func (l *richLogger) Slow(v ...any) { l.slow(fmt.Sprint(v...)) } -func (l *richLogger) Slowf(format string, v ...interface{}) { +func (l *richLogger) Slowf(format string, v ...any) { l.slow(fmt.Sprintf(format, v...)) } -func (l *richLogger) Slowv(v interface{}) { +func (l *richLogger) Slowv(v any) { l.slow(v) } @@ -156,25 +156,25 @@ func (l *richLogger) buildFields(fields ...LogField) []LogField { return fields } -func (l *richLogger) debug(v interface{}, fields ...LogField) { +func (l *richLogger) debug(v any, fields ...LogField) { if shallLog(DebugLevel) { getWriter().Debug(v, l.buildFields(fields...)...) } } -func (l *richLogger) err(v interface{}, fields ...LogField) { +func (l *richLogger) err(v any, fields ...LogField) { if shallLog(ErrorLevel) { getWriter().Error(v, l.buildFields(fields...)...) } } -func (l *richLogger) info(v interface{}, fields ...LogField) { +func (l *richLogger) info(v any, fields ...LogField) { if shallLog(InfoLevel) { getWriter().Info(v, l.buildFields(fields...)...) } } -func (l *richLogger) slow(v interface{}, fields ...LogField) { +func (l *richLogger) slow(v any, fields ...LogField) { if shallLog(ErrorLevel) { getWriter().Slow(v, l.buildFields(fields...)...) } diff --git a/core/logx/syslog_test.go b/core/logx/syslog_test.go index 2be0b51a..8591f16c 100644 --- a/core/logx/syslog_test.go +++ b/core/logx/syslog_test.go @@ -42,7 +42,7 @@ func captureOutput(f func()) string { } func getContent(jsonStr string) string { - var entry map[string]interface{} + var entry map[string]any json.Unmarshal([]byte(jsonStr), &entry) val, ok := entry[contentKey] diff --git a/core/logx/writer.go b/core/logx/writer.go index c6cd6d3d..74d247e8 100644 --- a/core/logx/writer.go +++ b/core/logx/writer.go @@ -16,15 +16,15 @@ import ( type ( Writer interface { - Alert(v interface{}) + Alert(v any) Close() error - Debug(v interface{}, fields ...LogField) - Error(v interface{}, fields ...LogField) - Info(v interface{}, fields ...LogField) - Severe(v interface{}) - Slow(v interface{}, fields ...LogField) - Stack(v interface{}) - Stat(v interface{}, fields ...LogField) + Debug(v any, fields ...LogField) + Error(v any, fields ...LogField) + Info(v any, fields ...LogField) + Severe(v any) + Slow(v any, fields ...LogField) + Stack(v any) + Stat(v any, fields ...LogField) } atomicWriter struct { @@ -171,7 +171,7 @@ func newFileWriter(c LogConf) (Writer, error) { }, nil } -func (w *concreteWriter) Alert(v interface{}) { +func (w *concreteWriter) Alert(v any) { output(w.errorLog, levelAlert, v) } @@ -195,62 +195,62 @@ func (w *concreteWriter) Close() error { return w.statLog.Close() } -func (w *concreteWriter) Debug(v interface{}, fields ...LogField) { +func (w *concreteWriter) Debug(v any, fields ...LogField) { output(w.infoLog, levelDebug, v, fields...) } -func (w *concreteWriter) Error(v interface{}, fields ...LogField) { +func (w *concreteWriter) Error(v any, fields ...LogField) { output(w.errorLog, levelError, v, fields...) } -func (w *concreteWriter) Info(v interface{}, fields ...LogField) { +func (w *concreteWriter) Info(v any, fields ...LogField) { output(w.infoLog, levelInfo, v, fields...) } -func (w *concreteWriter) Severe(v interface{}) { +func (w *concreteWriter) Severe(v any) { output(w.severeLog, levelFatal, v) } -func (w *concreteWriter) Slow(v interface{}, fields ...LogField) { +func (w *concreteWriter) Slow(v any, fields ...LogField) { output(w.slowLog, levelSlow, v, fields...) } -func (w *concreteWriter) Stack(v interface{}) { +func (w *concreteWriter) Stack(v any) { output(w.stackLog, levelError, v) } -func (w *concreteWriter) Stat(v interface{}, fields ...LogField) { +func (w *concreteWriter) Stat(v any, fields ...LogField) { output(w.statLog, levelStat, v, fields...) } type nopWriter struct{} -func (n nopWriter) Alert(_ interface{}) { +func (n nopWriter) Alert(_ any) { } func (n nopWriter) Close() error { return nil } -func (n nopWriter) Debug(_ interface{}, _ ...LogField) { +func (n nopWriter) Debug(_ any, _ ...LogField) { } -func (n nopWriter) Error(_ interface{}, _ ...LogField) { +func (n nopWriter) Error(_ any, _ ...LogField) { } -func (n nopWriter) Info(_ interface{}, _ ...LogField) { +func (n nopWriter) Info(_ any, _ ...LogField) { } -func (n nopWriter) Severe(_ interface{}) { +func (n nopWriter) Severe(_ any) { } -func (n nopWriter) Slow(_ interface{}, _ ...LogField) { +func (n nopWriter) Slow(_ any, _ ...LogField) { } -func (n nopWriter) Stack(_ interface{}) { +func (n nopWriter) Stack(_ any) { } -func (n nopWriter) Stat(_ interface{}, _ ...LogField) { +func (n nopWriter) Stat(_ any, _ ...LogField) { } func buildPlainFields(fields ...LogField) []string { @@ -277,7 +277,7 @@ func combineGlobalFields(fields []LogField) []LogField { return ret } -func output(writer io.Writer, level string, val interface{}, fields ...LogField) { +func output(writer io.Writer, level string, val any, fields ...LogField) { // only truncate string content, don't know how to truncate the values of other types. if v, ok := val.(string); ok { maxLen := atomic.LoadUint32(&maxContentLength) @@ -330,7 +330,7 @@ func wrapLevelWithColor(level string) string { return color.WithColorPadding(level, colour) } -func writeJson(writer io.Writer, info interface{}) { +func writeJson(writer io.Writer, info any) { if content, err := json.Marshal(info); err != nil { log.Println(err.Error()) } else if writer == nil { @@ -340,7 +340,7 @@ func writeJson(writer io.Writer, info interface{}) { } } -func writePlainAny(writer io.Writer, level string, val interface{}, fields ...string) { +func writePlainAny(writer io.Writer, level string, val any, fields ...string) { level = wrapLevelWithColor(level) switch v := val.(type) { @@ -377,7 +377,7 @@ func writePlainText(writer io.Writer, level, msg string, fields ...string) { } } -func writePlainValue(writer io.Writer, level string, val interface{}, fields ...string) { +func writePlainValue(writer io.Writer, level string, val any, fields ...string) { var buf bytes.Buffer buf.WriteString(getTimestamp()) buf.WriteByte(plainEncodingSep) diff --git a/core/mapping/jsonunmarshaler.go b/core/mapping/jsonunmarshaler.go index f832224d..cded8c95 100644 --- a/core/mapping/jsonunmarshaler.go +++ b/core/mapping/jsonunmarshaler.go @@ -11,17 +11,17 @@ const jsonTagKey = "json" var jsonUnmarshaler = NewUnmarshaler(jsonTagKey) // UnmarshalJsonBytes unmarshals content into v. -func UnmarshalJsonBytes(content []byte, v interface{}, opts ...UnmarshalOption) error { +func UnmarshalJsonBytes(content []byte, v any, opts ...UnmarshalOption) error { return unmarshalJsonBytes(content, v, getJsonUnmarshaler(opts...)) } // UnmarshalJsonMap unmarshals content from m into v. -func UnmarshalJsonMap(m map[string]interface{}, v interface{}, opts ...UnmarshalOption) error { +func UnmarshalJsonMap(m map[string]any, v any, opts ...UnmarshalOption) error { return getJsonUnmarshaler(opts...).Unmarshal(m, v) } // UnmarshalJsonReader unmarshals content from reader into v. -func UnmarshalJsonReader(reader io.Reader, v interface{}, opts ...UnmarshalOption) error { +func UnmarshalJsonReader(reader io.Reader, v any, opts ...UnmarshalOption) error { return unmarshalJsonReader(reader, v, getJsonUnmarshaler(opts...)) } @@ -33,8 +33,8 @@ func getJsonUnmarshaler(opts ...UnmarshalOption) *Unmarshaler { return jsonUnmarshaler } -func unmarshalJsonBytes(content []byte, v interface{}, unmarshaler *Unmarshaler) error { - var m interface{} +func unmarshalJsonBytes(content []byte, v any, unmarshaler *Unmarshaler) error { + var m any if err := jsonx.Unmarshal(content, &m); err != nil { return err } @@ -42,8 +42,8 @@ func unmarshalJsonBytes(content []byte, v interface{}, unmarshaler *Unmarshaler) return unmarshaler.Unmarshal(m, v) } -func unmarshalJsonReader(reader io.Reader, v interface{}, unmarshaler *Unmarshaler) error { - var m interface{} +func unmarshalJsonReader(reader io.Reader, v any, unmarshaler *Unmarshaler) error { + var m any if err := jsonx.UnmarshalFromReader(reader, &m); err != nil { return err } diff --git a/core/mapping/jsonunmarshaler_test.go b/core/mapping/jsonunmarshaler_test.go index 832ed24e..4d0de4d1 100644 --- a/core/mapping/jsonunmarshaler_test.go +++ b/core/mapping/jsonunmarshaler_test.go @@ -871,7 +871,7 @@ func TestUnmarshalReaderError(t *testing.T) { func TestUnmarshalMap(t *testing.T) { t.Run("nil map and valid", func(t *testing.T) { - var m map[string]interface{} + var m map[string]any var v struct { Any string `json:",optional"` } @@ -882,7 +882,7 @@ func TestUnmarshalMap(t *testing.T) { }) t.Run("empty map but not valid", func(t *testing.T) { - m := map[string]interface{}{} + m := map[string]any{} var v struct { Any string } @@ -892,7 +892,7 @@ func TestUnmarshalMap(t *testing.T) { }) t.Run("empty map and valid", func(t *testing.T) { - m := map[string]interface{}{} + m := map[string]any{} var v struct { Any string `json:",optional"` } @@ -905,7 +905,7 @@ func TestUnmarshalMap(t *testing.T) { }) t.Run("valid map", func(t *testing.T) { - m := map[string]interface{}{ + m := map[string]any{ "Any": "foo", } var v struct { diff --git a/core/mapping/marshaler.go b/core/mapping/marshaler.go index a10a79c6..c54ae747 100644 --- a/core/mapping/marshaler.go +++ b/core/mapping/marshaler.go @@ -13,8 +13,8 @@ const ( // Marshal marshals the given val and returns the map that contains the fields. // optional=another is not implemented, and it's hard to implement and not common used. -func Marshal(val interface{}) (map[string]map[string]interface{}, error) { - ret := make(map[string]map[string]interface{}) +func Marshal(val any) (map[string]map[string]any, error) { + ret := make(map[string]map[string]any) tp := reflect.TypeOf(val) if tp.Kind() == reflect.Ptr { tp = tp.Elem() @@ -45,7 +45,7 @@ func getTag(field reflect.StructField) (string, bool) { } func processMember(field reflect.StructField, value reflect.Value, - collector map[string]map[string]interface{}) error { + collector map[string]map[string]any) error { var key string var opt *fieldOptions var err error @@ -73,7 +73,7 @@ func processMember(field reflect.StructField, value reflect.Value, if ok { m[key] = val } else { - m = map[string]interface{}{ + m = map[string]any{ key: val, } } diff --git a/core/mapping/marshaler_test.go b/core/mapping/marshaler_test.go index 5e34dd85..176d3a37 100644 --- a/core/mapping/marshaler_test.go +++ b/core/mapping/marshaler_test.go @@ -227,7 +227,7 @@ func TestMarshal_Range(t *testing.T) { } func TestMarshal_RangeOut(t *testing.T) { - tests := []interface{}{ + tests := []any{ struct { Int int `json:"int,range=[1:3]"` }{ @@ -262,7 +262,7 @@ func TestMarshal_RangeOut(t *testing.T) { } func TestMarshal_RangeIllegal(t *testing.T) { - tests := []interface{}{ + tests := []any{ struct { Int int `json:"int,range=[3:1]"` }{ @@ -284,7 +284,7 @@ func TestMarshal_RangeIllegal(t *testing.T) { func TestMarshal_RangeLeftEqualsToRight(t *testing.T) { tests := []struct { name string - value interface{} + value any err error }{ { diff --git a/core/mapping/tomlunmarshaler.go b/core/mapping/tomlunmarshaler.go index ccf7731a..62db3d60 100644 --- a/core/mapping/tomlunmarshaler.go +++ b/core/mapping/tomlunmarshaler.go @@ -7,7 +7,7 @@ import ( ) // UnmarshalTomlBytes unmarshals TOML bytes into the given v. -func UnmarshalTomlBytes(content []byte, v interface{}, opts ...UnmarshalOption) error { +func UnmarshalTomlBytes(content []byte, v any, opts ...UnmarshalOption) error { b, err := encoding.TomlToJson(content) if err != nil { return err @@ -17,7 +17,7 @@ func UnmarshalTomlBytes(content []byte, v interface{}, opts ...UnmarshalOption) } // UnmarshalTomlReader unmarshals TOML from the given io.Reader into the given v. -func UnmarshalTomlReader(r io.Reader, v interface{}, opts ...UnmarshalOption) error { +func UnmarshalTomlReader(r io.Reader, v any, opts ...UnmarshalOption) error { b, err := io.ReadAll(r) if err != nil { return err diff --git a/core/mapping/unmarshaler.go b/core/mapping/unmarshaler.go index fee1457a..5dd18f65 100644 --- a/core/mapping/unmarshaler.go +++ b/core/mapping/unmarshaler.go @@ -30,9 +30,9 @@ var ( durationType = reflect.TypeOf(time.Duration(0)) cacheKeys = make(map[string][]string) cacheKeysLock sync.Mutex - defaultCache = make(map[string]interface{}) + defaultCache = make(map[string]any) defaultCacheLock sync.Mutex - emptyMap = map[string]interface{}{} + emptyMap = map[string]any{} emptyValue = reflect.ValueOf(lang.Placeholder) ) @@ -66,12 +66,12 @@ func NewUnmarshaler(key string, opts ...UnmarshalOption) *Unmarshaler { } // UnmarshalKey unmarshals m into v with tag key. -func UnmarshalKey(m map[string]interface{}, v interface{}) error { +func UnmarshalKey(m map[string]any, v any) error { return keyUnmarshaler.Unmarshal(m, v) } // Unmarshal unmarshals m into v. -func (u *Unmarshaler) Unmarshal(i interface{}, v interface{}) error { +func (u *Unmarshaler) Unmarshal(i any, v any) error { valueType := reflect.TypeOf(v) if valueType.Kind() != reflect.Ptr { return errValueNotSettable @@ -79,13 +79,13 @@ func (u *Unmarshaler) Unmarshal(i interface{}, v interface{}) error { elemType := Deref(valueType) switch iv := i.(type) { - case map[string]interface{}: + case map[string]any: if elemType.Kind() != reflect.Struct { return errTypeMismatch } return u.UnmarshalValuer(mapValuer(iv), v) - case []interface{}: + case []any: if elemType.Kind() != reflect.Slice { return errTypeMismatch } @@ -97,11 +97,11 @@ func (u *Unmarshaler) Unmarshal(i interface{}, v interface{}) error { } // UnmarshalValuer unmarshals m into v. -func (u *Unmarshaler) UnmarshalValuer(m Valuer, v interface{}) error { +func (u *Unmarshaler) UnmarshalValuer(m Valuer, v any) error { return u.unmarshalWithFullName(simpleValuer{current: m}, v, "") } -func (u *Unmarshaler) fillMap(fieldType reflect.Type, value reflect.Value, mapValue interface{}) error { +func (u *Unmarshaler) fillMap(fieldType reflect.Type, value reflect.Value, mapValue any) error { if !value.CanSet() { return errValueNotSettable } @@ -121,7 +121,7 @@ func (u *Unmarshaler) fillMap(fieldType reflect.Type, value reflect.Value, mapVa return nil } -func (u *Unmarshaler) fillMapFromString(value reflect.Value, mapValue interface{}) error { +func (u *Unmarshaler) fillMapFromString(value reflect.Value, mapValue any) error { if !value.CanSet() { return errValueNotSettable } @@ -142,7 +142,7 @@ func (u *Unmarshaler) fillMapFromString(value reflect.Value, mapValue interface{ return nil } -func (u *Unmarshaler) fillSlice(fieldType reflect.Type, value reflect.Value, mapValue interface{}) error { +func (u *Unmarshaler) fillSlice(fieldType reflect.Type, value reflect.Value, mapValue any) error { if !value.CanSet() { return errValueNotSettable } @@ -172,7 +172,7 @@ func (u *Unmarshaler) fillSlice(fieldType reflect.Type, value reflect.Value, map switch dereffedBaseKind { case reflect.Struct: target := reflect.New(dereffedBaseType) - if err := u.Unmarshal(ithValue.(map[string]interface{}), target.Interface()); err != nil { + if err := u.Unmarshal(ithValue.(map[string]any), target.Interface()); err != nil { return err } @@ -196,8 +196,8 @@ func (u *Unmarshaler) fillSlice(fieldType reflect.Type, value reflect.Value, map } func (u *Unmarshaler) fillSliceFromString(fieldType reflect.Type, value reflect.Value, - mapValue interface{}) error { - var slice []interface{} + mapValue any) error { + var slice []any switch v := mapValue.(type) { case fmt.Stringer: if err := jsonx.UnmarshalFromString(v.String(), &slice); err != nil { @@ -226,14 +226,14 @@ func (u *Unmarshaler) fillSliceFromString(fieldType reflect.Type, value reflect. } func (u *Unmarshaler) fillSliceValue(slice reflect.Value, index int, - baseKind reflect.Kind, value interface{}) error { + baseKind reflect.Kind, value any) error { ithVal := slice.Index(index) switch v := value.(type) { case fmt.Stringer: return setValueFromString(baseKind, ithVal, v.String()) case string: return setValueFromString(baseKind, ithVal, v) - case map[string]interface{}: + case map[string]any: return u.fillMap(ithVal.Type(), ithVal, value) default: // don't need to consider the difference between int, int8, int16, int32, int64, @@ -281,7 +281,7 @@ func (u *Unmarshaler) fillSliceWithDefault(derefedType reflect.Type, value refle return u.fillSlice(derefedType, value, slice) } -func (u *Unmarshaler) generateMap(keyType, elemType reflect.Type, mapValue interface{}) (reflect.Value, error) { +func (u *Unmarshaler) generateMap(keyType, elemType reflect.Type, mapValue any) (reflect.Value, error) { mapType := reflect.MapOf(keyType, elemType) valueType := reflect.TypeOf(mapValue) if mapType == valueType { @@ -306,7 +306,7 @@ func (u *Unmarshaler) generateMap(keyType, elemType reflect.Type, mapValue inter targetValue.SetMapIndex(key, target.Elem()) case reflect.Struct: - keythMap, ok := keythData.(map[string]interface{}) + keythMap, ok := keythData.(map[string]any) if !ok { return emptyValue, errTypeMismatch } @@ -318,7 +318,7 @@ func (u *Unmarshaler) generateMap(keyType, elemType reflect.Type, mapValue inter SetMapIndexValue(elemType, targetValue, key, target.Elem()) case reflect.Map: - keythMap, ok := keythData.(map[string]interface{}) + keythMap, ok := keythData.(map[string]any) if !ok { return emptyValue, errTypeMismatch } @@ -513,7 +513,7 @@ func (u *Unmarshaler) processFieldNotFromString(fieldType reflect.Type, value re switch { case valueKind == reflect.Map && typeKind == reflect.Struct: - mv, ok := mapValue.(map[string]interface{}) + mv, ok := mapValue.(map[string]any) if !ok { return errTypeMismatch } @@ -536,7 +536,7 @@ func (u *Unmarshaler) processFieldNotFromString(fieldType reflect.Type, value re } func (u *Unmarshaler) processFieldPrimitive(fieldType reflect.Type, value reflect.Value, - mapValue interface{}, opts *fieldOptionsWithContext, fullName string) error { + mapValue any, opts *fieldOptionsWithContext, fullName string) error { typeKind := Deref(fieldType).Kind() valueKind := reflect.TypeOf(mapValue).Kind() @@ -631,7 +631,7 @@ func (u *Unmarshaler) processFieldStruct(fieldType reflect.Type, value reflect.V } func (u *Unmarshaler) processFieldTextUnmarshaler(fieldType reflect.Type, value reflect.Value, - mapValue interface{}) (bool, error) { + mapValue any) (bool, error) { var tval encoding.TextUnmarshaler var ok bool @@ -756,7 +756,7 @@ func (u *Unmarshaler) processNamedFieldWithValue(fieldType reflect.Type, value r } func (u *Unmarshaler) processNamedFieldWithValueFromString(fieldType reflect.Type, value reflect.Value, - mapValue interface{}, key string, opts *fieldOptionsWithContext, fullName string) error { + mapValue any, key string, opts *fieldOptionsWithContext, fullName string) error { valueKind := reflect.TypeOf(mapValue).Kind() if valueKind != reflect.String { return fmt.Errorf("the value in map is not string, but %s", valueKind) @@ -832,7 +832,7 @@ func (u *Unmarshaler) processNamedFieldWithoutValue(fieldType reflect.Type, valu return nil } -func (u *Unmarshaler) unmarshalWithFullName(m valuerWithParent, v interface{}, fullName string) error { +func (u *Unmarshaler) unmarshalWithFullName(m valuerWithParent, v any, fullName string) error { rv := reflect.ValueOf(v) if err := ValidatePtr(&rv); err != nil { return err @@ -900,7 +900,7 @@ func fillDurationValue(fieldType reflect.Type, value reflect.Value, dur string) return nil } -func fillPrimitive(fieldType reflect.Type, value reflect.Value, mapValue interface{}, +func fillPrimitive(fieldType reflect.Type, value reflect.Value, mapValue any, opts *fieldOptionsWithContext, fullName string) error { if !value.CanSet() { return errValueNotSettable @@ -929,7 +929,7 @@ func fillPrimitive(fieldType reflect.Type, value reflect.Value, mapValue interfa } } -func fillWithSameType(fieldType reflect.Type, value reflect.Value, mapValue interface{}, +func fillWithSameType(fieldType reflect.Type, value reflect.Value, mapValue any, opts *fieldOptionsWithContext) error { if !value.CanSet() { return errValueNotSettable @@ -952,12 +952,12 @@ func fillWithSameType(fieldType reflect.Type, value reflect.Value, mapValue inte } // getValue gets the value for the specific key, the key can be in the format of parentKey.childKey -func getValue(m valuerWithParent, key string) (interface{}, bool) { +func getValue(m valuerWithParent, key string) (any, bool) { keys := readKeys(key) return getValueWithChainedKeys(m, keys) } -func getValueWithChainedKeys(m valuerWithParent, keys []string) (interface{}, bool) { +func getValueWithChainedKeys(m valuerWithParent, keys []string) (any, bool) { switch len(keys) { case 0: return nil, false @@ -966,7 +966,7 @@ func getValueWithChainedKeys(m valuerWithParent, keys []string) (interface{}, bo return v, ok default: if v, ok := m.Value(keys[0]); ok { - if nextm, ok := v.(map[string]interface{}); ok { + if nextm, ok := v.(map[string]any); ok { return getValueWithChainedKeys(recursiveValuer{ current: mapValuer(nextm), parent: m, @@ -1025,7 +1025,7 @@ func readKeys(key string) []string { return keys } -func setSameKindValue(targetType reflect.Type, target reflect.Value, value interface{}) { +func setSameKindValue(targetType reflect.Type, target reflect.Value, value any) { if reflect.ValueOf(value).Type().AssignableTo(targetType) { target.Set(reflect.ValueOf(value)) } else { diff --git a/core/mapping/unmarshaler_test.go b/core/mapping/unmarshaler_test.go index ca57cac5..ab0d6a42 100644 --- a/core/mapping/unmarshaler_test.go +++ b/core/mapping/unmarshaler_test.go @@ -20,14 +20,14 @@ import ( const maxUintBitsToTest = 62 func TestUnmarshalWithFullNameNotStruct(t *testing.T) { - var s map[string]interface{} + var s map[string]any content := []byte(`{"name":"xiaoming"}`) err := UnmarshalJsonBytes(content, &s) assert.Equal(t, errTypeMismatch, err) } func TestUnmarshalValueNotSettable(t *testing.T) { - var s map[string]interface{} + var s map[string]any content := []byte(`{"name":"xiaoming"}`) err := UnmarshalJsonBytes(content, s) assert.Equal(t, errValueNotSettable, err) @@ -39,7 +39,7 @@ func TestUnmarshalWithoutTagName(t *testing.T) { OptionalP *bool `key:",optional"` OptionalPP **bool `key:",optional"` } - m := map[string]interface{}{ + m := map[string]any{ "Optional": true, "OptionalP": true, "OptionalPP": true, @@ -57,7 +57,7 @@ func TestUnmarshalWithoutTagNameWithCanonicalKey(t *testing.T) { type inner struct { Name string `key:"name"` } - m := map[string]interface{}{ + m := map[string]any{ "Name": "go-zero", } @@ -82,7 +82,7 @@ func TestUnmarshalWithoutTagNameWithCanonicalKeyOptionalDep(t *testing.T) { FirstName string `key:",optional"` LastName string `key:",optional=FirstName"` } - m := map[string]interface{}{ + m := map[string]any{ "firstname": "go", "lastname": "zero", } @@ -108,7 +108,7 @@ func TestUnmarshalBool(t *testing.T) { DefaultTrue bool `key:"defaulttrue,default=1"` Optional bool `key:"optional,optional"` } - m := map[string]interface{}{ + m := map[string]any{ "yes": true, "no": false, "yesone": "1", @@ -138,7 +138,7 @@ func TestUnmarshalDuration(t *testing.T) { PtrDuration *time.Duration `key:"ptr"` PtrPtrDuration **time.Duration `key:"ptrptr"` } - m := map[string]interface{}{ + m := map[string]any{ "duration": "5s", "less": "100ms", "more": "24h", @@ -160,7 +160,7 @@ func TestUnmarshalDurationDefault(t *testing.T) { Int int `key:"int"` Duration time.Duration `key:"duration,default=5s"` } - m := map[string]interface{}{ + m := map[string]any{ "int": 5, } var in inner @@ -174,7 +174,7 @@ func TestUnmarshalDurationPtr(t *testing.T) { type inner struct { Duration *time.Duration `key:"duration"` } - m := map[string]interface{}{ + m := map[string]any{ "duration": "5s", } var in inner @@ -189,7 +189,7 @@ func TestUnmarshalDurationPtrDefault(t *testing.T) { Value *int `key:",default=5"` Duration *time.Duration `key:"duration,default=5s"` } - m := map[string]interface{}{ + m := map[string]any{ "int": 5, } var in inner @@ -215,7 +215,7 @@ func TestUnmarshalInt(t *testing.T) { DefaultInt int64 `key:"defaultint,default=11"` Optional int `key:"optional,optional"` } - m := map[string]interface{}{ + m := map[string]any{ "int": 1, "intstr": "2", "int8": int8(3), @@ -249,7 +249,7 @@ func TestUnmarshalIntPtr(t *testing.T) { type inner struct { Int *int `key:"int"` } - m := map[string]interface{}{ + m := map[string]any{ "int": 1, } @@ -265,7 +265,7 @@ func TestUnmarshalIntSliceOfPtr(t *testing.T) { Ints []*int `key:"ints"` Intps []**int `key:"intps"` } - m := map[string]interface{}{ + m := map[string]any{ "ints": []int{1, 2, 3}, "intps": []int{1, 2, 3, 4}, } @@ -293,7 +293,7 @@ func TestUnmarshalIntWithDefault(t *testing.T) { Intp *int `key:"intp,default=5"` Intpp **int `key:"intpp,default=5"` } - m := map[string]interface{}{ + m := map[string]any{ "int": 1, "intp": 2, "intpp": 3, @@ -314,7 +314,7 @@ func TestUnmarshalIntWithString(t *testing.T) { Intp *int64 `key:"intp,string"` Intpp **int64 `key:"intpp,string"` } - m := map[string]interface{}{ + m := map[string]any{ "int": json.Number("1"), "intp": json.Number("2"), "intpp": json.Number("3"), @@ -332,7 +332,7 @@ func TestUnmarshalIntWithString(t *testing.T) { type inner struct { Int *int64 `key:"int"` } - m := map[string]interface{}{ + m := map[string]any{ "int": json.Number("1"), } @@ -346,7 +346,7 @@ func TestUnmarshalIntWithString(t *testing.T) { type inner struct { Int **int64 `key:"int"` } - m := map[string]interface{}{ + m := map[string]any{ "int": json.Number("1"), } @@ -360,7 +360,7 @@ func TestUnmarshalIntWithString(t *testing.T) { type inner struct { Int int64 `key:"int,string,options=[0,1]"` } - m := map[string]interface{}{ + m := map[string]any{ "int": json.Number("1"), } @@ -374,7 +374,7 @@ func TestUnmarshalIntWithString(t *testing.T) { type inner struct { Int int64 `key:"int,string,options=[0,1]"` } - m := map[string]interface{}{ + m := map[string]any{ "int": nil, } @@ -390,7 +390,7 @@ func TestUnmarshalIntWithString(t *testing.T) { Int int64 `key:"int,string,options=[0,1]"` } ) - m := map[string]interface{}{ + m := map[string]any{ "int": StrType("1"), } @@ -405,7 +405,7 @@ func TestUnmarshalBoolSliceRequired(t *testing.T) { } var in inner - assert.NotNil(t, UnmarshalKey(map[string]interface{}{}, &in)) + assert.NotNil(t, UnmarshalKey(map[string]any{}, &in)) } func TestUnmarshalBoolSliceNil(t *testing.T) { @@ -414,7 +414,7 @@ func TestUnmarshalBoolSliceNil(t *testing.T) { } var in inner - if assert.NoError(t, UnmarshalKey(map[string]interface{}{}, &in)) { + if assert.NoError(t, UnmarshalKey(map[string]any{}, &in)) { assert.Nil(t, in.Bools) } } @@ -425,7 +425,7 @@ func TestUnmarshalBoolSliceNilExplicit(t *testing.T) { } var in inner - if assert.NoError(t, UnmarshalKey(map[string]interface{}{ + if assert.NoError(t, UnmarshalKey(map[string]any{ "bools": nil, }, &in)) { assert.Nil(t, in.Bools) @@ -438,7 +438,7 @@ func TestUnmarshalBoolSliceEmpty(t *testing.T) { } var in inner - if assert.NoError(t, UnmarshalKey(map[string]interface{}{ + if assert.NoError(t, UnmarshalKey(map[string]any{ "bools": []bool{}, }, &in)) { assert.Empty(t, in.Bools) @@ -554,7 +554,7 @@ func TestUnmarshalUint(t *testing.T) { DefaultUint uint `key:"defaultuint,default=11"` Optional uint `key:"optional,optional"` } - m := map[string]interface{}{ + m := map[string]any{ "uint": uint(1), "uintstr": "2", "uint8": uint8(3), @@ -593,7 +593,7 @@ func TestUnmarshalFloat(t *testing.T) { DefaultFloat float32 `key:"defaultfloat,default=5.5"` Optional float32 `key:",optional"` } - m := map[string]interface{}{ + m := map[string]any{ "float32": float32(1.5), "float32str": "2.5", "float64": float64(3.5), @@ -616,9 +616,9 @@ func TestUnmarshalInt64Slice(t *testing.T) { Ages []int64 `key:"ages"` Slice []int64 `key:"slice"` } - m := map[string]interface{}{ + m := map[string]any{ "ages": []int64{1, 2}, - "slice": []interface{}{}, + "slice": []any{}, } ast := assert.New(t) @@ -633,9 +633,9 @@ func TestUnmarshalIntSlice(t *testing.T) { Ages []int `key:"ages"` Slice []int `key:"slice"` } - m := map[string]interface{}{ + m := map[string]any{ "ages": []int{1, 2}, - "slice": []interface{}{}, + "slice": []any{}, } ast := assert.New(t) @@ -654,7 +654,7 @@ func TestUnmarshalString(t *testing.T) { DefaultString string `key:"defaultstring,default=hello"` Optional string `key:",optional"` } - m := map[string]interface{}{ + m := map[string]any{ "name": "kevin", "namestr": "namewithstring", } @@ -674,7 +674,7 @@ func TestUnmarshalStringWithMissing(t *testing.T) { type inner struct { Name string `key:"name"` } - m := map[string]interface{}{} + m := map[string]any{} var in inner assert.Error(t, UnmarshalKey(m, &in)) @@ -684,7 +684,7 @@ func TestUnmarshalStringSliceFromString(t *testing.T) { var v struct { Names []string `key:"names"` } - m := map[string]interface{}{ + m := map[string]any{ "names": `["first", "second"]`, } @@ -700,7 +700,7 @@ func TestUnmarshalIntSliceFromString(t *testing.T) { var v struct { Values []int `key:"values"` } - m := map[string]interface{}{ + m := map[string]any{ "values": `[1, 2]`, } @@ -716,7 +716,7 @@ func TestUnmarshalIntMapFromString(t *testing.T) { var v struct { Sort map[string]int `key:"sort"` } - m := map[string]interface{}{ + m := map[string]any{ "sort": `{"value":12345,"zeroVal":0,"nullVal":null}`, } @@ -733,7 +733,7 @@ func TestUnmarshalBoolMapFromString(t *testing.T) { var v struct { Sort map[string]bool `key:"sort"` } - m := map[string]interface{}{ + m := map[string]any{ "sort": `{"value":true,"zeroVal":false,"nullVal":null}`, } @@ -758,7 +758,7 @@ func TestUnmarshalStringMapFromStringer(t *testing.T) { var v struct { Sort map[string]string `key:"sort"` } - m := map[string]interface{}{ + m := map[string]any{ "sort": CustomStringer(`"value":"ascend","emptyStr":""`), } @@ -774,7 +774,7 @@ func TestUnmarshalStringMapFromUnsupportedType(t *testing.T) { var v struct { Sort map[string]string `key:"sort"` } - m := map[string]interface{}{ + m := map[string]any{ "sort": UnsupportedStringer(`{"value":"ascend","emptyStr":""}`), } @@ -787,7 +787,7 @@ func TestUnmarshalStringMapFromNotSettableValue(t *testing.T) { sort map[string]string `key:"sort"` psort *map[string]string `key:"psort"` } - m := map[string]interface{}{ + m := map[string]any{ "sort": `{"value":"ascend","emptyStr":""}`, "psort": `{"value":"ascend","emptyStr":""}`, } @@ -800,7 +800,7 @@ func TestUnmarshalStringMapFromString(t *testing.T) { var v struct { Sort map[string]string `key:"sort"` } - m := map[string]interface{}{ + m := map[string]any{ "sort": `{"value":"ascend","emptyStr":""}`, } @@ -822,7 +822,7 @@ func TestUnmarshalStructMapFromString(t *testing.T) { Field5 []string `json:"field5"` } `key:"filter"` } - m := map[string]interface{}{ + m := map[string]any{ "filter": `{"obj":{"field1":true,"field2":"1573570455447539712","field3":"this is a string", "field4":"this is a string pointer","field5":["str1","str2"]}}`, } @@ -843,7 +843,7 @@ func TestUnmarshalStringSliceMapFromString(t *testing.T) { var v struct { Filter map[string][]string `key:"filter"` } - m := map[string]interface{}{ + m := map[string]any{ "filter": `{"assignType":null,"status":["process","comment"],"rate":[]}`, } @@ -871,17 +871,17 @@ func TestUnmarshalStruct(t *testing.T) { AddressP *address `key:"addressp"` AddressPP **address `key:"addresspp"` } - m := map[string]interface{}{ + m := map[string]any{ "name": "kevin", - "address": map[string]interface{}{ + "address": map[string]any{ "city": "shanghai", "zipcode": "200000", }, - "addressp": map[string]interface{}{ + "addressp": map[string]any{ "city": "beijing", "zipcode": "300000", }, - "addresspp": map[string]interface{}{ + "addresspp": map[string]any{ "city": "guangzhou", "zipcode": "400000", }, @@ -944,14 +944,14 @@ func TestUnmarshalStructOptionalDepends(t *testing.T) { for _, test := range tests { t.Run(stringx.Rand(), func(t *testing.T) { - m := map[string]interface{}{ + m := map[string]any{ "name": "kevin", - "address": map[string]interface{}{ + "address": map[string]any{ "city": "shanghai", }, } for k, v := range test.input { - m["address"].(map[string]interface{})[k] = v + m["address"].(map[string]any)[k] = v } var in inner @@ -1012,14 +1012,14 @@ func TestUnmarshalStructOptionalDependsNot(t *testing.T) { for _, test := range tests { t.Run(stringx.Rand(), func(t *testing.T) { - m := map[string]interface{}{ + m := map[string]any{ "name": "kevin", - "address": map[string]interface{}{ + "address": map[string]any{ "city": "shanghai", }, } for k, v := range test.input { - m["address"].(map[string]interface{})[k] = v + m["address"].(map[string]any)[k] = v } var in inner @@ -1048,7 +1048,7 @@ func TestUnmarshalStructOptionalDependsNotErrorDetails(t *testing.T) { Address address `key:"address"` } - m := map[string]interface{}{ + m := map[string]any{ "name": "kevin", } @@ -1070,7 +1070,7 @@ func TestUnmarshalStructOptionalDependsNotNested(t *testing.T) { Combo combo `key:"combo"` } - m := map[string]interface{}{ + m := map[string]any{ "name": "kevin", } @@ -1092,7 +1092,7 @@ func TestUnmarshalStructOptionalNestedDifferentKey(t *testing.T) { Combo combo `key:"combo"` } - m := map[string]interface{}{ + m := map[string]any{ "name": "kevin", } @@ -1110,9 +1110,9 @@ func TestUnmarshalStructOptionalDependsNotEnoughValue(t *testing.T) { Address address `key:"address"` } - m := map[string]interface{}{ + m := map[string]any{ "name": "kevin", - "address": map[string]interface{}{}, + "address": map[string]any{}, } var in inner @@ -1129,9 +1129,9 @@ func TestUnmarshalStructOptionalDependsMoreValues(t *testing.T) { Address address `key:"address"` } - m := map[string]interface{}{ + m := map[string]any{ "name": "kevin", - "address": map[string]interface{}{}, + "address": map[string]any{}, } var in inner @@ -1148,7 +1148,7 @@ func TestUnmarshalStructMissing(t *testing.T) { Address address `key:"address"` } - m := map[string]interface{}{ + m := map[string]any{ "name": "kevin", } @@ -1170,9 +1170,9 @@ func TestUnmarshalNestedStructMissing(t *testing.T) { Address address `key:"address"` } - m := map[string]interface{}{ + m := map[string]any{ "name": "kevin", - "address": map[string]interface{}{}, + "address": map[string]any{}, } var in inner @@ -1220,7 +1220,7 @@ func TestUnmarshalAnonymousStructOptionalDepends(t *testing.T) { for _, test := range tests { t.Run(stringx.Rand(), func(t *testing.T) { - m := map[string]interface{}{ + m := map[string]any{ "name": "kevin", "city": "shanghai", } @@ -1255,9 +1255,9 @@ func TestUnmarshalStructPtr(t *testing.T) { Name string `key:"name"` Address *address `key:"address"` } - m := map[string]interface{}{ + m := map[string]any{ "name": "kevin", - "address": map[string]interface{}{ + "address": map[string]any{ "city": "shanghai", "zipcode": "200000", }, @@ -1290,7 +1290,7 @@ func TestUnmarshalWithStringIgnored(t *testing.T) { Float32 float32 `key:"float32"` Float64 float64 `key:"float64"` } - m := map[string]interface{}{ + m := map[string]any{ "yes": "1", "no": "0", "int": "1", @@ -1333,7 +1333,7 @@ func TestUnmarshalJsonNumberInt64(t *testing.T) { var intValue int64 = 1 << uint(i) strValue := strconv.FormatInt(intValue, 10) number := json.Number(strValue) - m := map[string]interface{}{ + m := map[string]any{ "ID": number, } var v struct { @@ -1350,7 +1350,7 @@ func TestUnmarshalJsonNumberUint64(t *testing.T) { var intValue uint64 = 1 << uint(i) strValue := strconv.FormatUint(intValue, 10) number := json.Number(strValue) - m := map[string]interface{}{ + m := map[string]any{ "ID": number, } var v struct { @@ -1367,7 +1367,7 @@ func TestUnmarshalJsonNumberUint64Ptr(t *testing.T) { var intValue uint64 = 1 << uint(i) strValue := strconv.FormatUint(intValue, 10) number := json.Number(strValue) - m := map[string]interface{}{ + m := map[string]any{ "ID": number, } var v struct { @@ -1382,7 +1382,7 @@ func TestUnmarshalJsonNumberUint64Ptr(t *testing.T) { } func TestUnmarshalMapOfInt(t *testing.T) { - m := map[string]interface{}{ + m := map[string]any{ "Ids": map[string]bool{"first": true}, } var v struct { @@ -1394,8 +1394,8 @@ func TestUnmarshalMapOfInt(t *testing.T) { } func TestUnmarshalMapOfStructError(t *testing.T) { - m := map[string]interface{}{ - "Ids": map[string]interface{}{"first": "second"}, + m := map[string]any{ + "Ids": map[string]any{"first": "second"}, } var v struct { Ids map[string]struct { @@ -1406,8 +1406,8 @@ func TestUnmarshalMapOfStructError(t *testing.T) { } func TestUnmarshalSlice(t *testing.T) { - m := map[string]interface{}{ - "Ids": []interface{}{"first", "second"}, + m := map[string]any{ + "Ids": []any{"first", "second"}, } var v struct { Ids []string @@ -1421,8 +1421,8 @@ func TestUnmarshalSlice(t *testing.T) { } func TestUnmarshalSliceOfStruct(t *testing.T) { - m := map[string]interface{}{ - "Ids": []map[string]interface{}{ + m := map[string]any{ + "Ids": []map[string]any{ { "First": 1, "Second": 2, @@ -1449,7 +1449,7 @@ func TestUnmarshalWithStringOptionsCorrect(t *testing.T) { Foo string `key:"foo,options=[bar,baz]"` Correct string `key:"correct,options=1|2"` } - m := map[string]interface{}{ + m := map[string]any{ "value": "first", "foo": "bar", "correct": "2", @@ -1471,7 +1471,7 @@ func TestUnmarshalOptionsOptional(t *testing.T) { Foo string `key:"foo,options=[bar,baz]"` Correct string `key:"correct,options=1|2"` } - m := map[string]interface{}{ + m := map[string]any{ "value": "first", "foo": "bar", "correct": "2", @@ -1493,7 +1493,7 @@ func TestUnmarshalOptionsOptionalWrongValue(t *testing.T) { OptionalValue string `key:"optional_value,options=first|second,optional"` WrongValue string `key:"wrong_value,options=first|second,optional"` } - m := map[string]interface{}{ + m := map[string]any{ "value": "first", "wrong_value": "third", } @@ -1506,7 +1506,7 @@ func TestUnmarshalOptionsMissingValues(t *testing.T) { type inner struct { Value string `key:"value,options"` } - m := map[string]interface{}{ + m := map[string]any{ "value": "first", } @@ -1519,7 +1519,7 @@ func TestUnmarshalStringOptionsWithStringOptionsNotString(t *testing.T) { Value string `key:"value,options=first|second"` Correct string `key:"correct,options=1|2"` } - m := map[string]interface{}{ + m := map[string]any{ "value": "first", "correct": 2, } @@ -1534,7 +1534,7 @@ func TestUnmarshalStringOptionsWithStringOptions(t *testing.T) { Value string `key:"value,options=first|second"` Correct string `key:"correct,options=1|2"` } - m := map[string]interface{}{ + m := map[string]any{ "value": "first", "correct": "2", } @@ -1554,7 +1554,7 @@ func TestUnmarshalStringOptionsWithStringOptionsPtr(t *testing.T) { ValueP **string `key:"valuep,options=first|second"` Correct *int `key:"correct,options=1|2"` } - m := map[string]interface{}{ + m := map[string]any{ "value": "first", "valuep": "second", "correct": "2", @@ -1575,7 +1575,7 @@ func TestUnmarshalStringOptionsWithStringOptionsIncorrect(t *testing.T) { Value string `key:"value,options=first|second"` Correct string `key:"correct,options=1|2"` } - m := map[string]interface{}{ + m := map[string]any{ "value": "third", "correct": "2", } @@ -1590,7 +1590,7 @@ func TestUnmarshalStringOptionsWithStringOptionsIncorrectGrouped(t *testing.T) { Value string `key:"value,options=[first,second]"` Correct string `key:"correct,options=1|2"` } - m := map[string]interface{}{ + m := map[string]any{ "value": "third", "correct": "2", } @@ -1605,7 +1605,7 @@ func TestUnmarshalWithStringOptionsIncorrect(t *testing.T) { Value string `key:"value,options=first|second"` Incorrect string `key:"incorrect,options=1|2"` } - m := map[string]interface{}{ + m := map[string]any{ "value": "first", "incorrect": "3", } @@ -1619,7 +1619,7 @@ func TestUnmarshalWithIntOptionsCorrect(t *testing.T) { Value string `key:"value,options=first|second"` Number int `key:"number,options=1|2"` } - m := map[string]interface{}{ + m := map[string]any{ "value": "first", "number": 2, } @@ -1637,7 +1637,7 @@ func TestUnmarshalWithIntOptionsCorrectPtr(t *testing.T) { Value *string `key:"value,options=first|second"` Number *int `key:"number,options=1|2"` } - m := map[string]interface{}{ + m := map[string]any{ "value": "first", "number": 2, } @@ -1655,7 +1655,7 @@ func TestUnmarshalWithIntOptionsIncorrect(t *testing.T) { Value string `key:"value,options=first|second"` Incorrect int `key:"incorrect,options=1|2"` } - m := map[string]interface{}{ + m := map[string]any{ "value": "first", "incorrect": 3, } @@ -1669,7 +1669,7 @@ func TestUnmarshalWithJsonNumberOptionsIncorrect(t *testing.T) { Value string `key:"value,options=first|second"` Incorrect int `key:"incorrect,options=1|2"` } - m := map[string]interface{}{ + m := map[string]any{ "value": "first", "incorrect": json.Number("3"), } @@ -1691,7 +1691,7 @@ func TestUnmarshalWithUintOptionsCorrect(t *testing.T) { Value string `key:"value,options=first|second"` Number uint `key:"number,options=1|2"` } - m := map[string]interface{}{ + m := map[string]any{ "value": "first", "number": uint(2), } @@ -1709,7 +1709,7 @@ func TestUnmarshalWithUintOptionsIncorrect(t *testing.T) { Value string `key:"value,options=first|second"` Incorrect uint `key:"incorrect,options=1|2"` } - m := map[string]interface{}{ + m := map[string]any{ "value": "first", "incorrect": uint(3), } @@ -1722,7 +1722,7 @@ func TestUnmarshalWithOptionsAndDefault(t *testing.T) { type inner struct { Value string `key:"value,options=first|second|third,default=second"` } - m := map[string]interface{}{} + m := map[string]any{} var in inner if assert.NoError(t, UnmarshalKey(m, &in)) { @@ -1734,7 +1734,7 @@ func TestUnmarshalWithOptionsAndSet(t *testing.T) { type inner struct { Value string `key:"value,options=first|second|third,default=second"` } - m := map[string]interface{}{ + m := map[string]any{ "value": "first", } @@ -1748,9 +1748,9 @@ func TestUnmarshalNestedKey(t *testing.T) { var c struct { ID int `json:"Persons.first.ID"` } - m := map[string]interface{}{ - "Persons": map[string]interface{}{ - "first": map[string]interface{}{ + m := map[string]any{ + "Persons": map[string]any{ + "first": map[string]any{ "ID": 1, }, }, @@ -1767,9 +1767,9 @@ func TestUnmarhsalNestedKeyArray(t *testing.T) { ID int } `json:"Persons.first"` } - m := map[string]interface{}{ - "Persons": map[string]interface{}{ - "first": []map[string]interface{}{ + m := map[string]any{ + "Persons": map[string]any{ + "first": []map[string]any{ {"ID": 1}, {"ID": 2}, }, @@ -1792,7 +1792,7 @@ func TestUnmarshalAnonymousOptionalRequiredProvided(t *testing.T) { Foo `json:",optional"` } ) - m := map[string]interface{}{ + m := map[string]any{ "v": "anything", } @@ -1812,7 +1812,7 @@ func TestUnmarshalAnonymousOptionalRequiredMissed(t *testing.T) { Foo `json:",optional"` } ) - m := map[string]interface{}{} + m := map[string]any{} var b Bar if assert.NoError(t, NewUnmarshaler("json").Unmarshal(m, &b)) { @@ -1830,7 +1830,7 @@ func TestUnmarshalAnonymousOptionalOptionalProvided(t *testing.T) { Foo `json:",optional"` } ) - m := map[string]interface{}{ + m := map[string]any{ "v": "anything", } @@ -1850,7 +1850,7 @@ func TestUnmarshalAnonymousOptionalOptionalMissed(t *testing.T) { Foo `json:",optional"` } ) - m := map[string]interface{}{} + m := map[string]any{} var b Bar if assert.NoError(t, NewUnmarshaler("json").Unmarshal(m, &b)) { @@ -1869,7 +1869,7 @@ func TestUnmarshalAnonymousOptionalRequiredBothProvided(t *testing.T) { Foo `json:",optional"` } ) - m := map[string]interface{}{ + m := map[string]any{ "n": "kevin", "v": "anything", } @@ -1892,7 +1892,7 @@ func TestUnmarshalAnonymousOptionalRequiredOneProvidedOneMissed(t *testing.T) { Foo `json:",optional"` } ) - m := map[string]interface{}{ + m := map[string]any{ "v": "anything", } @@ -1911,7 +1911,7 @@ func TestUnmarshalAnonymousOptionalRequiredBothMissed(t *testing.T) { Foo `json:",optional"` } ) - m := map[string]interface{}{} + m := map[string]any{} var b Bar if assert.NoError(t, NewUnmarshaler("json").Unmarshal(m, &b)) { @@ -1931,7 +1931,7 @@ func TestUnmarshalAnonymousOptionalOneRequiredOneOptionalBothProvided(t *testing Foo `json:",optional"` } ) - m := map[string]interface{}{ + m := map[string]any{ "n": "kevin", "v": "anything", } @@ -1954,7 +1954,7 @@ func TestUnmarshalAnonymousOptionalOneRequiredOneOptionalBothMissed(t *testing.T Foo `json:",optional"` } ) - m := map[string]interface{}{} + m := map[string]any{} var b Bar if assert.NoError(t, NewUnmarshaler("json").Unmarshal(m, &b)) { @@ -1974,7 +1974,7 @@ func TestUnmarshalAnonymousOptionalOneRequiredOneOptionalRequiredProvidedOptiona Foo `json:",optional"` } ) - m := map[string]interface{}{ + m := map[string]any{ "v": "anything", } @@ -1996,7 +1996,7 @@ func TestUnmarshalAnonymousOptionalOneRequiredOneOptionalRequiredMissedOptionalP Foo `json:",optional"` } ) - m := map[string]interface{}{ + m := map[string]any{ "n": "anything", } @@ -2015,7 +2015,7 @@ func TestUnmarshalAnonymousOptionalBothOptionalBothProvided(t *testing.T) { Foo `json:",optional"` } ) - m := map[string]interface{}{ + m := map[string]any{ "n": "kevin", "v": "anything", } @@ -2038,7 +2038,7 @@ func TestUnmarshalAnonymousOptionalBothOptionalOneProvidedOneMissed(t *testing.T Foo `json:",optional"` } ) - m := map[string]interface{}{ + m := map[string]any{ "v": "anything", } @@ -2060,7 +2060,7 @@ func TestUnmarshalAnonymousOptionalBothOptionalBothMissed(t *testing.T) { Foo `json:",optional"` } ) - m := map[string]interface{}{} + m := map[string]any{} var b Bar if assert.NoError(t, NewUnmarshaler("json").Unmarshal(m, &b)) { @@ -2079,7 +2079,7 @@ func TestUnmarshalAnonymousRequiredProvided(t *testing.T) { Foo } ) - m := map[string]interface{}{ + m := map[string]any{ "v": "anything", } @@ -2099,7 +2099,7 @@ func TestUnmarshalAnonymousRequiredMissed(t *testing.T) { Foo } ) - m := map[string]interface{}{} + m := map[string]any{} var b Bar assert.Error(t, NewUnmarshaler("json").Unmarshal(m, &b)) @@ -2115,7 +2115,7 @@ func TestUnmarshalAnonymousOptionalProvided(t *testing.T) { Foo } ) - m := map[string]interface{}{ + m := map[string]any{ "v": "anything", } @@ -2135,7 +2135,7 @@ func TestUnmarshalAnonymousOptionalMissed(t *testing.T) { Foo } ) - m := map[string]interface{}{} + m := map[string]any{} var b Bar if assert.NoError(t, NewUnmarshaler("json").Unmarshal(m, &b)) { @@ -2154,7 +2154,7 @@ func TestUnmarshalAnonymousRequiredBothProvided(t *testing.T) { Foo } ) - m := map[string]interface{}{ + m := map[string]any{ "n": "kevin", "v": "anything", } @@ -2177,7 +2177,7 @@ func TestUnmarshalAnonymousRequiredOneProvidedOneMissed(t *testing.T) { Foo } ) - m := map[string]interface{}{ + m := map[string]any{ "v": "anything", } @@ -2196,7 +2196,7 @@ func TestUnmarshalAnonymousRequiredBothMissed(t *testing.T) { Foo } ) - m := map[string]interface{}{ + m := map[string]any{ "v": "anything", } @@ -2215,7 +2215,7 @@ func TestUnmarshalAnonymousOneRequiredOneOptionalBothProvided(t *testing.T) { Foo } ) - m := map[string]interface{}{ + m := map[string]any{ "n": "kevin", "v": "anything", } @@ -2238,7 +2238,7 @@ func TestUnmarshalAnonymousOneRequiredOneOptionalBothMissed(t *testing.T) { Foo } ) - m := map[string]interface{}{} + m := map[string]any{} var b Bar assert.Error(t, NewUnmarshaler("json").Unmarshal(m, &b)) @@ -2255,7 +2255,7 @@ func TestUnmarshalAnonymousOneRequiredOneOptionalRequiredProvidedOptionalMissed( Foo } ) - m := map[string]interface{}{ + m := map[string]any{ "v": "anything", } @@ -2277,7 +2277,7 @@ func TestUnmarshalAnonymousOneRequiredOneOptionalRequiredMissedOptionalProvided( Foo } ) - m := map[string]interface{}{ + m := map[string]any{ "n": "anything", } @@ -2296,7 +2296,7 @@ func TestUnmarshalAnonymousBothOptionalBothProvided(t *testing.T) { Foo } ) - m := map[string]interface{}{ + m := map[string]any{ "n": "kevin", "v": "anything", } @@ -2319,7 +2319,7 @@ func TestUnmarshalAnonymousBothOptionalOneProvidedOneMissed(t *testing.T) { Foo } ) - m := map[string]interface{}{ + m := map[string]any{ "v": "anything", } @@ -2341,7 +2341,7 @@ func TestUnmarshalAnonymousBothOptionalBothMissed(t *testing.T) { Foo } ) - m := map[string]interface{}{} + m := map[string]any{} var b Bar if assert.NoError(t, NewUnmarshaler("json").Unmarshal(m, &b)) { @@ -2361,8 +2361,8 @@ func TestUnmarshalAnonymousWrappedToMuch(t *testing.T) { Foo } ) - m := map[string]interface{}{ - "Foo": map[string]interface{}{ + m := map[string]any{ + "Foo": map[string]any{ "n": "name", "v": "anything", }, @@ -2382,8 +2382,8 @@ func TestUnmarshalWrappedObject(t *testing.T) { Inner Foo } ) - m := map[string]interface{}{ - "Inner": map[string]interface{}{ + m := map[string]any{ + "Inner": map[string]any{ "v": "anything", }, } @@ -2406,7 +2406,7 @@ func TestUnmarshalWrappedObjectOptional(t *testing.T) { Name string } ) - m := map[string]interface{}{ + m := map[string]any{ "Name": "anything", } @@ -2429,8 +2429,8 @@ func TestUnmarshalWrappedObjectOptionalFilled(t *testing.T) { } ) hosts := []string{"1", "2"} - m := map[string]interface{}{ - "Inner": map[string]interface{}{ + m := map[string]any{ + "Inner": map[string]any{ "Hosts": hosts, "Key": "key", }, @@ -2457,8 +2457,8 @@ func TestUnmarshalWrappedNamedObjectOptional(t *testing.T) { Name string } ) - m := map[string]interface{}{ - "Inner": map[string]interface{}{ + m := map[string]any{ + "Inner": map[string]any{ "Host": "thehost", "Key": "thekey", }, @@ -2483,8 +2483,8 @@ func TestUnmarshalWrappedObjectNamedPtr(t *testing.T) { Inner *Foo `json:"foo,optional"` } ) - m := map[string]interface{}{ - "foo": map[string]interface{}{ + m := map[string]any{ + "foo": map[string]any{ "v": "anything", }, } @@ -2505,8 +2505,8 @@ func TestUnmarshalWrappedObjectPtr(t *testing.T) { Inner *Foo } ) - m := map[string]interface{}{ - "Inner": map[string]interface{}{ + m := map[string]any{ + "Inner": map[string]any{ "v": "anything", }, } @@ -2521,7 +2521,7 @@ func TestUnmarshalInt2String(t *testing.T) { type inner struct { Int string `key:"int"` } - m := map[string]interface{}{ + m := map[string]any{ "int": 123, } @@ -2535,7 +2535,7 @@ func TestUnmarshalZeroValues(t *testing.T) { Int int `key:"int"` String string `key:"string"` } - m := map[string]interface{}{ + m := map[string]any{ "no": false, "int": 0, "string": "", @@ -2556,7 +2556,7 @@ func TestUnmarshalUsingDifferentKeys(t *testing.T) { Int int `key:"int"` String string `bson:"string"` } - m := map[string]interface{}{ + m := map[string]any{ "no": false, "int": 9, "string": "value", @@ -2584,7 +2584,7 @@ func TestUnmarshalNumberRangeInt(t *testing.T) { Value10 uint32 `key:"value10,range=[1:5],string"` Value11 uint64 `key:"value11,range=[1:5],string"` } - m := map[string]interface{}{ + m := map[string]any{ "value1": 10, "value2": int8(1), "value3": int16(2), @@ -2619,7 +2619,7 @@ func TestUnmarshalNumberRangeJsonNumber(t *testing.T) { Value4 uint8 `key:"value4,range=(1:5]"` Value5 uint16 `key:"value5,range=(1:5]"` } - m := map[string]interface{}{ + m := map[string]any{ "value3": json.Number("2"), "value4": json.Number("4"), "value5": json.Number("5"), @@ -2636,7 +2636,7 @@ func TestUnmarshalNumberRangeJsonNumber(t *testing.T) { type inner1 struct { Value int `key:"value,range=(1:5]"` } - m = map[string]interface{}{ + m = map[string]any{ "value": json.Number("a"), } @@ -2653,7 +2653,7 @@ func TestUnmarshalNumberRangeIntLeftExclude(t *testing.T) { Value10 int `key:"value10,range=(1:5],string"` Value11 int `key:"value11,range=(1:5],string"` } - m := map[string]interface{}{ + m := map[string]any{ "value3": uint(2), "value4": uint32(4), "value5": uint64(5), @@ -2683,7 +2683,7 @@ func TestUnmarshalNumberRangeIntRightExclude(t *testing.T) { Value9 int `key:"value9,range=[1:5),string"` Value10 int `key:"value10,range=[1:5),string"` } - m := map[string]interface{}{ + m := map[string]any{ "value2": uint(1), "value3": uint8(2), "value4": uint16(4), @@ -2711,7 +2711,7 @@ func TestUnmarshalNumberRangeIntExclude(t *testing.T) { Value9 int `key:"value9,range=(1:5),string"` Value10 int `key:"value10,range=(1:5),string"` } - m := map[string]interface{}{ + m := map[string]any{ "value3": 2, "value4": 4, "value9": "2", @@ -2734,16 +2734,16 @@ func TestUnmarshalNumberRangeIntOutOfRange(t *testing.T) { } var in1 inner1 - assert.Equal(t, errNumberRange, UnmarshalKey(map[string]interface{}{ + assert.Equal(t, errNumberRange, UnmarshalKey(map[string]any{ "value": int64(1), }, &in1)) - assert.Equal(t, errNumberRange, UnmarshalKey(map[string]interface{}{ + assert.Equal(t, errNumberRange, UnmarshalKey(map[string]any{ "value": int64(0), }, &in1)) - assert.Equal(t, errNumberRange, UnmarshalKey(map[string]interface{}{ + assert.Equal(t, errNumberRange, UnmarshalKey(map[string]any{ "value": int64(5), }, &in1)) - assert.Equal(t, errNumberRange, UnmarshalKey(map[string]interface{}{ + assert.Equal(t, errNumberRange, UnmarshalKey(map[string]any{ "value": json.Number("6"), }, &in1)) @@ -2752,10 +2752,10 @@ func TestUnmarshalNumberRangeIntOutOfRange(t *testing.T) { } var in2 inner2 - assert.Equal(t, errNumberRange, UnmarshalKey(map[string]interface{}{ + assert.Equal(t, errNumberRange, UnmarshalKey(map[string]any{ "value": int64(0), }, &in2)) - assert.Equal(t, errNumberRange, UnmarshalKey(map[string]interface{}{ + assert.Equal(t, errNumberRange, UnmarshalKey(map[string]any{ "value": int64(5), }, &in2)) @@ -2764,10 +2764,10 @@ func TestUnmarshalNumberRangeIntOutOfRange(t *testing.T) { } var in3 inner3 - assert.Equal(t, errNumberRange, UnmarshalKey(map[string]interface{}{ + assert.Equal(t, errNumberRange, UnmarshalKey(map[string]any{ "value": int64(1), }, &in3)) - assert.Equal(t, errNumberRange, UnmarshalKey(map[string]interface{}{ + assert.Equal(t, errNumberRange, UnmarshalKey(map[string]any{ "value": int64(6), }, &in3)) @@ -2776,10 +2776,10 @@ func TestUnmarshalNumberRangeIntOutOfRange(t *testing.T) { } var in4 inner4 - assert.Equal(t, errNumberRange, UnmarshalKey(map[string]interface{}{ + assert.Equal(t, errNumberRange, UnmarshalKey(map[string]any{ "value": int64(0), }, &in4)) - assert.Equal(t, errNumberRange, UnmarshalKey(map[string]interface{}{ + assert.Equal(t, errNumberRange, UnmarshalKey(map[string]any{ "value": int64(6), }, &in4)) } @@ -2795,7 +2795,7 @@ func TestUnmarshalNumberRangeFloat(t *testing.T) { Value10 float64 `key:"value10,range=[1:5],string"` Value11 float64 `key:"value11,range=[1:5],string"` } - m := map[string]interface{}{ + m := map[string]any{ "value2": float32(1), "value3": float32(2), "value4": float64(4), @@ -2829,7 +2829,7 @@ func TestUnmarshalNumberRangeFloatLeftExclude(t *testing.T) { Value10 float64 `key:"value10,range=(1:5],string"` Value11 float64 `key:"value11,range=(1:5],string"` } - m := map[string]interface{}{ + m := map[string]any{ "value3": float64(2), "value4": float64(4), "value5": float64(5), @@ -2859,7 +2859,7 @@ func TestUnmarshalNumberRangeFloatRightExclude(t *testing.T) { Value9 float64 `key:"value9,range=[1:5),string"` Value10 float64 `key:"value10,range=[1:5),string"` } - m := map[string]interface{}{ + m := map[string]any{ "value2": float64(1), "value3": float64(2), "value4": float64(4), @@ -2887,7 +2887,7 @@ func TestUnmarshalNumberRangeFloatExclude(t *testing.T) { Value9 float64 `key:"value9,range=(1:5),string"` Value10 float64 `key:"value10,range=(1:5),string"` } - m := map[string]interface{}{ + m := map[string]any{ "value3": float64(2), "value4": float64(4), "value9": "2", @@ -2910,16 +2910,16 @@ func TestUnmarshalNumberRangeFloatOutOfRange(t *testing.T) { } var in1 inner1 - assert.Equal(t, errNumberRange, UnmarshalKey(map[string]interface{}{ + assert.Equal(t, errNumberRange, UnmarshalKey(map[string]any{ "value": float64(1), }, &in1)) - assert.Equal(t, errNumberRange, UnmarshalKey(map[string]interface{}{ + assert.Equal(t, errNumberRange, UnmarshalKey(map[string]any{ "value": float64(0), }, &in1)) - assert.Equal(t, errNumberRange, UnmarshalKey(map[string]interface{}{ + assert.Equal(t, errNumberRange, UnmarshalKey(map[string]any{ "value": float64(5), }, &in1)) - assert.Equal(t, errNumberRange, UnmarshalKey(map[string]interface{}{ + assert.Equal(t, errNumberRange, UnmarshalKey(map[string]any{ "value": json.Number("6"), }, &in1)) @@ -2928,10 +2928,10 @@ func TestUnmarshalNumberRangeFloatOutOfRange(t *testing.T) { } var in2 inner2 - assert.Equal(t, errNumberRange, UnmarshalKey(map[string]interface{}{ + assert.Equal(t, errNumberRange, UnmarshalKey(map[string]any{ "value": float64(0), }, &in2)) - assert.Equal(t, errNumberRange, UnmarshalKey(map[string]interface{}{ + assert.Equal(t, errNumberRange, UnmarshalKey(map[string]any{ "value": float64(5), }, &in2)) @@ -2940,10 +2940,10 @@ func TestUnmarshalNumberRangeFloatOutOfRange(t *testing.T) { } var in3 inner3 - assert.Equal(t, errNumberRange, UnmarshalKey(map[string]interface{}{ + assert.Equal(t, errNumberRange, UnmarshalKey(map[string]any{ "value": float64(1), }, &in3)) - assert.Equal(t, errNumberRange, UnmarshalKey(map[string]interface{}{ + assert.Equal(t, errNumberRange, UnmarshalKey(map[string]any{ "value": float64(6), }, &in3)) @@ -2952,10 +2952,10 @@ func TestUnmarshalNumberRangeFloatOutOfRange(t *testing.T) { } var in4 inner4 - assert.Equal(t, errNumberRange, UnmarshalKey(map[string]interface{}{ + assert.Equal(t, errNumberRange, UnmarshalKey(map[string]any{ "value": float64(0), }, &in4)) - assert.Equal(t, errNumberRange, UnmarshalKey(map[string]interface{}{ + assert.Equal(t, errNumberRange, UnmarshalKey(map[string]any{ "value": float64(6), }, &in4)) } @@ -2965,7 +2965,7 @@ func TestUnmarshalRangeError(t *testing.T) { Value int `key:",range="` } var in1 inner1 - assert.Equal(t, errNumberRange, UnmarshalKey(map[string]interface{}{ + assert.Equal(t, errNumberRange, UnmarshalKey(map[string]any{ "Value": 1, }, &in1)) @@ -2973,7 +2973,7 @@ func TestUnmarshalRangeError(t *testing.T) { Value int `key:",range=["` } var in2 inner2 - assert.Equal(t, errNumberRange, UnmarshalKey(map[string]interface{}{ + assert.Equal(t, errNumberRange, UnmarshalKey(map[string]any{ "Value": 1, }, &in2)) @@ -2981,7 +2981,7 @@ func TestUnmarshalRangeError(t *testing.T) { Value int `key:",range=[:"` } var in3 inner3 - assert.Equal(t, errNumberRange, UnmarshalKey(map[string]interface{}{ + assert.Equal(t, errNumberRange, UnmarshalKey(map[string]any{ "Value": 1, }, &in3)) @@ -2989,7 +2989,7 @@ func TestUnmarshalRangeError(t *testing.T) { Value int `key:",range=[:]"` } var in4 inner4 - assert.Equal(t, errNumberRange, UnmarshalKey(map[string]interface{}{ + assert.Equal(t, errNumberRange, UnmarshalKey(map[string]any{ "Value": 1, }, &in4)) @@ -2997,7 +2997,7 @@ func TestUnmarshalRangeError(t *testing.T) { Value int `key:",range={:]"` } var in5 inner5 - assert.Equal(t, errNumberRange, UnmarshalKey(map[string]interface{}{ + assert.Equal(t, errNumberRange, UnmarshalKey(map[string]any{ "Value": 1, }, &in5)) @@ -3005,7 +3005,7 @@ func TestUnmarshalRangeError(t *testing.T) { Value int `key:",range=[:}"` } var in6 inner6 - assert.Equal(t, errNumberRange, UnmarshalKey(map[string]interface{}{ + assert.Equal(t, errNumberRange, UnmarshalKey(map[string]any{ "Value": 1, }, &in6)) @@ -3013,7 +3013,7 @@ func TestUnmarshalRangeError(t *testing.T) { Value int `key:",range=[]"` } var in7 inner7 - assert.Equal(t, errNumberRange, UnmarshalKey(map[string]interface{}{ + assert.Equal(t, errNumberRange, UnmarshalKey(map[string]any{ "Value": 1, }, &in7)) @@ -3021,7 +3021,7 @@ func TestUnmarshalRangeError(t *testing.T) { Value int `key:",range=[a:]"` } var in8 inner8 - assert.Error(t, UnmarshalKey(map[string]interface{}{ + assert.Error(t, UnmarshalKey(map[string]any{ "Value": 1, }, &in8)) @@ -3029,7 +3029,7 @@ func TestUnmarshalRangeError(t *testing.T) { Value int `key:",range=[:a]"` } var in9 inner9 - assert.Error(t, UnmarshalKey(map[string]interface{}{ + assert.Error(t, UnmarshalKey(map[string]any{ "Value": 1, }, &in9)) @@ -3037,7 +3037,7 @@ func TestUnmarshalRangeError(t *testing.T) { Value int `key:",range"` } var in10 inner10 - assert.Error(t, UnmarshalKey(map[string]interface{}{ + assert.Error(t, UnmarshalKey(map[string]any{ "Value": 1, }, &in10)) @@ -3045,7 +3045,7 @@ func TestUnmarshalRangeError(t *testing.T) { Value int `key:",range=[1,2]"` } var in11 inner11 - assert.Equal(t, errNumberRange, UnmarshalKey(map[string]interface{}{ + assert.Equal(t, errNumberRange, UnmarshalKey(map[string]any{ "Value": "a", }, &in11)) } @@ -3054,8 +3054,8 @@ func TestUnmarshalNestedMap(t *testing.T) { var c struct { Anything map[string]map[string]string `json:"anything"` } - m := map[string]interface{}{ - "anything": map[string]map[string]interface{}{ + m := map[string]any{ + "anything": map[string]map[string]any{ "inner": { "id": "1", "name": "any", @@ -3072,8 +3072,8 @@ func TestUnmarshalNestedMapMismatch(t *testing.T) { var c struct { Anything map[string]map[string]map[string]string `json:"anything"` } - m := map[string]interface{}{ - "anything": map[string]map[string]interface{}{ + m := map[string]any{ + "anything": map[string]map[string]any{ "inner": { "name": "any", }, @@ -3087,8 +3087,8 @@ func TestUnmarshalNestedMapSimple(t *testing.T) { var c struct { Anything map[string]string `json:"anything"` } - m := map[string]interface{}{ - "anything": map[string]interface{}{ + m := map[string]any{ + "anything": map[string]any{ "id": "1", "name": "any", }, @@ -3103,7 +3103,7 @@ func TestUnmarshalNestedMapSimpleTypeMatch(t *testing.T) { var c struct { Anything map[string]string `json:"anything"` } - m := map[string]interface{}{ + m := map[string]any{ "anything": map[string]string{ "id": "1", "name": "any", @@ -3128,9 +3128,9 @@ func TestUnmarshalInheritPrimitiveUseParent(t *testing.T) { ) var s server - if assert.NoError(t, UnmarshalKey(map[string]interface{}{ + if assert.NoError(t, UnmarshalKey(map[string]any{ "discovery": "localhost:8080", - "component": map[string]interface{}{ + "component": map[string]any{ "name": "test", }, }, &s)) { @@ -3152,9 +3152,9 @@ func TestUnmarshalInheritPrimitiveUseSelf(t *testing.T) { ) var s server - if assert.NoError(t, UnmarshalKey(map[string]interface{}{ + if assert.NoError(t, UnmarshalKey(map[string]any{ "discovery": "localhost:8080", - "component": map[string]interface{}{ + "component": map[string]any{ "name": "test", "discovery": "localhost:8888", }, @@ -3176,8 +3176,8 @@ func TestUnmarshalInheritPrimitiveNotExist(t *testing.T) { ) var s server - assert.Error(t, UnmarshalKey(map[string]interface{}{ - "component": map[string]interface{}{ + assert.Error(t, UnmarshalKey(map[string]any{ + "component": map[string]any{ "name": "test", }, }, &s)) @@ -3200,12 +3200,12 @@ func TestUnmarshalInheritStructUseParent(t *testing.T) { ) var s server - if assert.NoError(t, UnmarshalKey(map[string]interface{}{ - "discovery": map[string]interface{}{ + if assert.NoError(t, UnmarshalKey(map[string]any{ + "discovery": map[string]any{ "host": "localhost", "port": 8080, }, - "component": map[string]interface{}{ + "component": map[string]any{ "name": "test", }, }, &s)) { @@ -3233,14 +3233,14 @@ func TestUnmarshalInheritStructUseSelf(t *testing.T) { ) var s server - if assert.NoError(t, UnmarshalKey(map[string]interface{}{ - "discovery": map[string]interface{}{ + if assert.NoError(t, UnmarshalKey(map[string]any{ + "discovery": map[string]any{ "host": "localhost", "port": 8080, }, - "component": map[string]interface{}{ + "component": map[string]any{ "name": "test", - "discovery": map[string]interface{}{ + "discovery": map[string]any{ "host": "remotehost", "port": 8888, }, @@ -3269,8 +3269,8 @@ func TestUnmarshalInheritStructNotExist(t *testing.T) { ) var s server - assert.Error(t, UnmarshalKey(map[string]interface{}{ - "component": map[string]interface{}{ + assert.Error(t, UnmarshalKey(map[string]any{ + "component": map[string]any{ "name": "test", }, }, &s)) @@ -3293,14 +3293,14 @@ func TestUnmarshalInheritStructUsePartial(t *testing.T) { ) var s server - if assert.NoError(t, UnmarshalKey(map[string]interface{}{ - "discovery": map[string]interface{}{ + if assert.NoError(t, UnmarshalKey(map[string]any{ + "discovery": map[string]any{ "host": "localhost", "port": 8080, }, - "component": map[string]interface{}{ + "component": map[string]any{ "name": "test", - "discovery": map[string]interface{}{ + "discovery": map[string]any{ "port": 8888, }, }, @@ -3329,11 +3329,11 @@ func TestUnmarshalInheritStructUseSelfIncorrectType(t *testing.T) { ) var s server - assert.Error(t, UnmarshalKey(map[string]interface{}{ - "discovery": map[string]interface{}{ + assert.Error(t, UnmarshalKey(map[string]any{ + "discovery": map[string]any{ "host": "localhost", }, - "component": map[string]interface{}{ + "component": map[string]any{ "name": "test", "discovery": map[string]string{ "host": "remotehost", @@ -3358,10 +3358,10 @@ func TestUnmarshaler_InheritFromGrandparent(t *testing.T) { ) var s server - if assert.NoError(t, UnmarshalKey(map[string]interface{}{ + if assert.NoError(t, UnmarshalKey(map[string]any{ "discovery": "localhost:8080", - "middle": map[string]interface{}{ - "value": map[string]interface{}{ + "middle": map[string]any{ + "value": map[string]any{ "name": "test", }, }, @@ -3503,7 +3503,7 @@ func TestUnmarshal_EnvStringOverwrite(t *testing.T) { defer os.Unsetenv(envName) var v Value - if assert.NoError(t, UnmarshalKey(map[string]interface{}{ + if assert.NoError(t, UnmarshalKey(map[string]any{ "name": "local value", }, &v)) { assert.Equal(t, envVal, v.Name) @@ -3541,7 +3541,7 @@ func TestUnmarshal_EnvIntOverwrite(t *testing.T) { defer os.Unsetenv(envName) var v Value - if assert.NoError(t, UnmarshalKey(map[string]interface{}{ + if assert.NoError(t, UnmarshalKey(map[string]any{ "age": 18, }, &v)) { assert.Equal(t, 123, v.Age) @@ -3579,7 +3579,7 @@ func TestUnmarshal_EnvFloatOverwrite(t *testing.T) { defer os.Unsetenv(envName) var v Value - if assert.NoError(t, UnmarshalKey(map[string]interface{}{ + if assert.NoError(t, UnmarshalKey(map[string]any{ "age": 18.5, }, &v)) { assert.Equal(t, float32(123.45), v.Age) @@ -3982,7 +3982,7 @@ func TestGoogleUUID(t *testing.T) { }) t.Run("map", func(t *testing.T) { - if assert.NoError(t, UnmarshalJsonMap(map[string]interface{}{ + if assert.NoError(t, UnmarshalJsonMap(map[string]any{ "uid": []byte("6ba7b810-9dad-11d1-80b4-00c04fd430c1"), "uidp": []byte("6ba7b810-9dad-11d1-80b4-00c04fd430c2"), "uidpp": []byte("6ba7b810-9dad-11d1-80b4-00c04fd430c3"), @@ -4054,8 +4054,8 @@ func TestUnmarshalJsonReaderWithMismatchTypeBoolMap(t *testing.T) { var req struct { Params map[string]string `json:"params"` } - assert.Equal(t, errTypeMismatch, UnmarshalJsonMap(map[string]interface{}{ - "params": map[string]interface{}{ + assert.Equal(t, errTypeMismatch, UnmarshalJsonMap(map[string]any{ + "params": map[string]any{ "a": true, }, }, &req)) @@ -4240,7 +4240,7 @@ func TestUnmarshalNestedPtr(t *testing.T) { type inner struct { Int **int `key:"int"` } - m := map[string]interface{}{ + m := map[string]any{ "int": 1, } @@ -4255,7 +4255,7 @@ func TestUnmarshalStructPtrOfPtr(t *testing.T) { type inner struct { Int int `key:"int"` } - m := map[string]interface{}{ + m := map[string]any{ "int": 1, } @@ -4282,7 +4282,7 @@ func BenchmarkUnmarshalString(b *testing.B) { type inner struct { Value string `key:"value"` } - m := map[string]interface{}{ + m := map[string]any{ "value": "first", } @@ -4297,8 +4297,8 @@ func BenchmarkUnmarshalString(b *testing.B) { func BenchmarkUnmarshalStruct(b *testing.B) { b.ReportAllocs() - m := map[string]interface{}{ - "Ids": []map[string]interface{}{ + m := map[string]any{ + "Ids": []map[string]any{ { "First": 1, "Second": 2, @@ -4320,7 +4320,7 @@ func BenchmarkUnmarshalStruct(b *testing.B) { } func BenchmarkMapToStruct(b *testing.B) { - data := map[string]interface{}{ + data := map[string]any{ "valid": "1", "age": "5", "name": "liao", @@ -4348,7 +4348,7 @@ func BenchmarkMapToStruct(b *testing.B) { } func BenchmarkUnmarshal(b *testing.B) { - data := map[string]interface{}{ + data := map[string]any{ "valid": "1", "age": "5", "name": "liao", diff --git a/core/mapping/utils.go b/core/mapping/utils.go index 1dc22c20..5ac706fe 100644 --- a/core/mapping/utils.go +++ b/core/mapping/utils.go @@ -64,7 +64,7 @@ func Deref(t reflect.Type) reflect.Type { } // Repr returns the string representation of v. -func Repr(v interface{}) string { +func Repr(v any) string { return lang.Repr(v) } @@ -89,7 +89,7 @@ func ValidatePtr(v *reflect.Value) error { return nil } -func convertTypeFromString(kind reflect.Kind, str string) (interface{}, error) { +func convertTypeFromString(kind reflect.Kind, str string) (any, error) { switch kind { case reflect.Bool: switch strings.ToLower(str) { @@ -484,7 +484,7 @@ func parseSegments(val string) []string { return segments } -func setMatchedPrimitiveValue(kind reflect.Kind, value reflect.Value, v interface{}) error { +func setMatchedPrimitiveValue(kind reflect.Kind, value reflect.Value, v any) error { switch kind { case reflect.Bool: value.SetBool(v.(bool)) @@ -536,7 +536,7 @@ func structValueRequired(tag string, tp reflect.Type) (bool, error) { return required, err } -func toFloat64(v interface{}) (float64, bool) { +func toFloat64(v any) (float64, bool) { switch val := v.(type) { case int: return float64(val), true @@ -623,7 +623,7 @@ func validateNumberRange(fv float64, nr *numberRange) error { return nil } -func validateValueInOptions(val interface{}, options []string) error { +func validateValueInOptions(val any, options []string) error { if len(options) > 0 { switch v := val.(type) { case string: @@ -640,7 +640,7 @@ func validateValueInOptions(val interface{}, options []string) error { return nil } -func validateValueRange(mapValue interface{}, opts *fieldOptionsWithContext) error { +func validateValueRange(mapValue any, opts *fieldOptionsWithContext) error { if opts == nil || opts.Range == nil { return nil } diff --git a/core/mapping/utils_test.go b/core/mapping/utils_test.go index 35398973..854ffa46 100644 --- a/core/mapping/utils_test.go +++ b/core/mapping/utils_test.go @@ -258,7 +258,7 @@ func TestSetValueFormatErrors(t *testing.T) { IntValue int UintValue uint FloatValue float32 - MapValue map[string]interface{} + MapValue map[string]any } var bar Bar diff --git a/core/mapping/valuer.go b/core/mapping/valuer.go index 8df2cc09..37f0b3bd 100644 --- a/core/mapping/valuer.go +++ b/core/mapping/valuer.go @@ -4,7 +4,7 @@ type ( // A Valuer interface defines the way to get values from the underlying object with keys. Valuer interface { // Value gets the value associated with the given key. - Value(key string) (interface{}, bool) + Value(key string) (any, bool) } // A valuerWithParent defines a node that has a parent node. @@ -22,12 +22,12 @@ type ( // A valueWithParent is used to wrap the value with its parent. valueWithParent struct { - value interface{} + value any parent valuerWithParent } // mapValuer is a type for map to meet the Valuer interface. - mapValuer map[string]interface{} + mapValuer map[string]any // simpleValuer is a type to get value from current node. simpleValuer node // recursiveValuer is a type to get the value recursively from current and parent nodes. @@ -35,13 +35,13 @@ type ( ) // Value gets the value assciated with the given key from mv. -func (mv mapValuer) Value(key string) (interface{}, bool) { +func (mv mapValuer) Value(key string) (any, bool) { v, ok := mv[key] return v, ok } // Value gets the value associated with the given key from sv. -func (sv simpleValuer) Value(key string) (interface{}, bool) { +func (sv simpleValuer) Value(key string) (any, bool) { v, ok := sv.current.Value(key) return v, ok } @@ -60,7 +60,7 @@ func (sv simpleValuer) Parent() valuerWithParent { // Value gets the value associated with the given key from rv, // and it will inherit the value from parent nodes. -func (rv recursiveValuer) Value(key string) (interface{}, bool) { +func (rv recursiveValuer) Value(key string) (any, bool) { val, ok := rv.current.Value(key) if !ok { if parent := rv.Parent(); parent != nil { @@ -70,7 +70,7 @@ func (rv recursiveValuer) Value(key string) (interface{}, bool) { return nil, false } - vm, ok := val.(map[string]interface{}) + vm, ok := val.(map[string]any) if !ok { return val, true } @@ -85,7 +85,7 @@ func (rv recursiveValuer) Value(key string) (interface{}, bool) { return val, true } - pm, ok := pv.(map[string]interface{}) + pm, ok := pv.(map[string]any) if !ok { return val, true } diff --git a/core/mapping/valuer_test.go b/core/mapping/valuer_test.go index f154ac1b..5f62d331 100644 --- a/core/mapping/valuer_test.go +++ b/core/mapping/valuer_test.go @@ -7,17 +7,17 @@ import ( ) func TestMapValuerWithInherit_Value(t *testing.T) { - input := map[string]interface{}{ - "discovery": map[string]interface{}{ + input := map[string]any{ + "discovery": map[string]any{ "host": "localhost", "port": 8080, }, - "component": map[string]interface{}{ + "component": map[string]any{ "name": "test", }, } valuer := recursiveValuer{ - current: mapValuer(input["component"].(map[string]interface{})), + current: mapValuer(input["component"].(map[string]any)), parent: simpleValuer{ current: mapValuer(input), }, @@ -26,24 +26,24 @@ func TestMapValuerWithInherit_Value(t *testing.T) { val, ok := valuer.Value("discovery") assert.True(t, ok) - m, ok := val.(map[string]interface{}) + m, ok := val.(map[string]any) assert.True(t, ok) assert.Equal(t, "localhost", m["host"]) assert.Equal(t, 8080, m["port"]) } func TestRecursiveValuer_Value(t *testing.T) { - input := map[string]interface{}{ - "component": map[string]interface{}{ + input := map[string]any{ + "component": map[string]any{ "name": "test", - "foo": map[string]interface{}{ + "foo": map[string]any{ "bar": "baz", }, }, "foo": "value", } valuer := recursiveValuer{ - current: mapValuer(input["component"].(map[string]interface{})), + current: mapValuer(input["component"].(map[string]any)), parent: simpleValuer{ current: mapValuer(input), }, @@ -51,7 +51,7 @@ func TestRecursiveValuer_Value(t *testing.T) { val, ok := valuer.Value("foo") assert.True(t, ok) - assert.EqualValues(t, map[string]interface{}{ + assert.EqualValues(t, map[string]any{ "bar": "baz", }, val) } diff --git a/core/mapping/yamlunmarshaler.go b/core/mapping/yamlunmarshaler.go index ad354cdb..f6e22810 100644 --- a/core/mapping/yamlunmarshaler.go +++ b/core/mapping/yamlunmarshaler.go @@ -7,7 +7,7 @@ import ( ) // UnmarshalYamlBytes unmarshals content into v. -func UnmarshalYamlBytes(content []byte, v interface{}, opts ...UnmarshalOption) error { +func UnmarshalYamlBytes(content []byte, v any, opts ...UnmarshalOption) error { b, err := encoding.YamlToJson(content) if err != nil { return err @@ -17,7 +17,7 @@ func UnmarshalYamlBytes(content []byte, v interface{}, opts ...UnmarshalOption) } // UnmarshalYamlReader unmarshals content from reader into v. -func UnmarshalYamlReader(reader io.Reader, v interface{}, opts ...UnmarshalOption) error { +func UnmarshalYamlReader(reader io.Reader, v any, opts ...UnmarshalOption) error { b, err := io.ReadAll(reader) if err != nil { return err diff --git a/core/mathx/entropy.go b/core/mathx/entropy.go index fd3f2851..5afab28d 100644 --- a/core/mathx/entropy.go +++ b/core/mathx/entropy.go @@ -5,7 +5,7 @@ import "math" const epsilon = 1e-6 // CalcEntropy calculates the entropy of m. -func CalcEntropy(m map[interface{}]int) float64 { +func CalcEntropy(m map[any]int) float64 { if len(m) == 0 || len(m) == 1 { return 1 } diff --git a/core/mathx/entropy_test.go b/core/mathx/entropy_test.go index 33e1a905..3b6c2659 100644 --- a/core/mathx/entropy_test.go +++ b/core/mathx/entropy_test.go @@ -9,7 +9,7 @@ import ( func TestCalcEntropy(t *testing.T) { const total = 1000 const count = 100 - m := make(map[interface{}]int, total) + m := make(map[any]int, total) for i := 0; i < total; i++ { m[i] = count } diff --git a/core/mathx/unstable_test.go b/core/mathx/unstable_test.go index 2db5fb53..0cb3cdd5 100644 --- a/core/mathx/unstable_test.go +++ b/core/mathx/unstable_test.go @@ -61,7 +61,7 @@ func TestUnstable_Distribution(t *testing.T) { _, ok := m[0] assert.False(t, ok) - mi := make(map[interface{}]int, len(m)) + mi := make(map[any]int, len(m)) for k, v := range m { mi[k] = v } diff --git a/core/mr/mapreduce.go b/core/mr/mapreduce.go index 108c505e..e5ab7041 100644 --- a/core/mr/mapreduce.go +++ b/core/mr/mapreduce.go @@ -24,29 +24,29 @@ var ( type ( // ForEachFunc is used to do element processing, but no output. - ForEachFunc func(item interface{}) + ForEachFunc func(item any) // GenerateFunc is used to let callers send elements into source. - GenerateFunc func(source chan<- interface{}) + GenerateFunc func(source chan<- any) // MapFunc is used to do element processing and write the output to writer. - MapFunc func(item interface{}, writer Writer) + MapFunc func(item any, writer Writer) // MapperFunc is used to do element processing and write the output to writer, // use cancel func to cancel the processing. - MapperFunc func(item interface{}, writer Writer, cancel func(error)) + MapperFunc func(item any, writer Writer, cancel func(error)) // ReducerFunc is used to reduce all the mapping output and write to writer, // use cancel func to cancel the processing. - ReducerFunc func(pipe <-chan interface{}, writer Writer, cancel func(error)) + ReducerFunc func(pipe <-chan any, writer Writer, cancel func(error)) // VoidReducerFunc is used to reduce all the mapping output, but no output. // Use cancel func to cancel the processing. - VoidReducerFunc func(pipe <-chan interface{}, cancel func(error)) + VoidReducerFunc func(pipe <-chan any, cancel func(error)) // Option defines the method to customize the mapreduce. Option func(opts *mapReduceOptions) mapperContext struct { ctx context.Context mapper MapFunc - source <-chan interface{} + source <-chan any panicChan *onceChan - collector chan<- interface{} + collector chan<- any doneChan <-chan lang.PlaceholderType workers int } @@ -58,7 +58,7 @@ type ( // Writer interface wraps Write method. Writer interface { - Write(v interface{}) + Write(v any) } ) @@ -68,16 +68,16 @@ func Finish(fns ...func() error) error { return nil } - return MapReduceVoid(func(source chan<- interface{}) { + return MapReduceVoid(func(source chan<- any) { for _, fn := range fns { source <- fn } - }, func(item interface{}, writer Writer, cancel func(error)) { + }, func(item any, writer Writer, cancel func(error)) { fn := item.(func() error) if err := fn(); err != nil { cancel(err) } - }, func(pipe <-chan interface{}, cancel func(error)) { + }, func(pipe <-chan any, cancel func(error)) { }, WithWorkers(len(fns))) } @@ -87,11 +87,11 @@ func FinishVoid(fns ...func()) { return } - ForEach(func(source chan<- interface{}) { + ForEach(func(source chan<- any) { for _, fn := range fns { source <- fn } - }, func(item interface{}) { + }, func(item any) { fn := item.(func()) fn() }, WithWorkers(len(fns))) @@ -100,14 +100,14 @@ func FinishVoid(fns ...func()) { // ForEach maps all elements from given generate but no output. func ForEach(generate GenerateFunc, mapper ForEachFunc, opts ...Option) { options := buildOptions(opts...) - panicChan := &onceChan{channel: make(chan interface{})} + panicChan := &onceChan{channel: make(chan any)} source := buildSource(generate, panicChan) - collector := make(chan interface{}) + collector := make(chan any) done := make(chan lang.PlaceholderType) go executeMappers(mapperContext{ ctx: options.ctx, - mapper: func(item interface{}, _ Writer) { + mapper: func(item any, _ Writer) { mapper(item) }, source: source, @@ -132,25 +132,25 @@ func ForEach(generate GenerateFunc, mapper ForEachFunc, opts ...Option) { // MapReduce maps all elements generated from given generate func, // and reduces the output elements with given reducer. func MapReduce(generate GenerateFunc, mapper MapperFunc, reducer ReducerFunc, - opts ...Option) (interface{}, error) { - panicChan := &onceChan{channel: make(chan interface{})} + opts ...Option) (any, error) { + panicChan := &onceChan{channel: make(chan any)} source := buildSource(generate, panicChan) return mapReduceWithPanicChan(source, panicChan, mapper, reducer, opts...) } // MapReduceChan maps all elements from source, and reduce the output elements with given reducer. -func MapReduceChan(source <-chan interface{}, mapper MapperFunc, reducer ReducerFunc, - opts ...Option) (interface{}, error) { - panicChan := &onceChan{channel: make(chan interface{})} +func MapReduceChan(source <-chan any, mapper MapperFunc, reducer ReducerFunc, + opts ...Option) (any, error) { + panicChan := &onceChan{channel: make(chan any)} return mapReduceWithPanicChan(source, panicChan, mapper, reducer, opts...) } // mapReduceWithPanicChan maps all elements from source, and reduce the output elements with given reducer. -func mapReduceWithPanicChan(source <-chan interface{}, panicChan *onceChan, mapper MapperFunc, - reducer ReducerFunc, opts ...Option) (interface{}, error) { +func mapReduceWithPanicChan(source <-chan any, panicChan *onceChan, mapper MapperFunc, + reducer ReducerFunc, opts ...Option) (any, error) { options := buildOptions(opts...) // output is used to write the final result - output := make(chan interface{}) + output := make(chan any) defer func() { // reducer can only write once, if more, panic for range output { @@ -159,7 +159,7 @@ func mapReduceWithPanicChan(source <-chan interface{}, panicChan *onceChan, mapp }() // collector is used to collect data from mapper, and consume in reducer - collector := make(chan interface{}, options.workers) + collector := make(chan any, options.workers) // if done is closed, all mappers and reducer should stop processing done := make(chan lang.PlaceholderType) writer := newGuardedWriter(options.ctx, output, done) @@ -197,7 +197,7 @@ func mapReduceWithPanicChan(source <-chan interface{}, panicChan *onceChan, mapp go executeMappers(mapperContext{ ctx: options.ctx, - mapper: func(item interface{}, w Writer) { + mapper: func(item any, w Writer) { mapper(item, w, cancel) }, source: source, @@ -229,7 +229,7 @@ func mapReduceWithPanicChan(source <-chan interface{}, panicChan *onceChan, mapp // MapReduceVoid maps all elements generated from given generate, // and reduce the output elements with given reducer. func MapReduceVoid(generate GenerateFunc, mapper MapperFunc, reducer VoidReducerFunc, opts ...Option) error { - _, err := MapReduce(generate, mapper, func(input <-chan interface{}, writer Writer, cancel func(error)) { + _, err := MapReduce(generate, mapper, func(input <-chan any, writer Writer, cancel func(error)) { reducer(input, cancel) }, opts...) if errors.Is(err, ErrReduceNoOutput) { @@ -266,8 +266,8 @@ func buildOptions(opts ...Option) *mapReduceOptions { return options } -func buildSource(generate GenerateFunc, panicChan *onceChan) chan interface{} { - source := make(chan interface{}) +func buildSource(generate GenerateFunc, panicChan *onceChan) chan any { + source := make(chan any) go func() { defer func() { if r := recover(); r != nil { @@ -283,7 +283,7 @@ func buildSource(generate GenerateFunc, panicChan *onceChan) chan interface{} { } // drain drains the channel. -func drain(channel <-chan interface{}) { +func drain(channel <-chan any) { // drain the channel for range channel { } @@ -348,11 +348,11 @@ func once(fn func(error)) func(error) { type guardedWriter struct { ctx context.Context - channel chan<- interface{} + channel chan<- any done <-chan lang.PlaceholderType } -func newGuardedWriter(ctx context.Context, channel chan<- interface{}, +func newGuardedWriter(ctx context.Context, channel chan<- any, done <-chan lang.PlaceholderType) guardedWriter { return guardedWriter{ ctx: ctx, @@ -361,7 +361,7 @@ func newGuardedWriter(ctx context.Context, channel chan<- interface{}, } } -func (gw guardedWriter) Write(v interface{}) { +func (gw guardedWriter) Write(v any) { select { case <-gw.ctx.Done(): return @@ -373,11 +373,11 @@ func (gw guardedWriter) Write(v interface{}) { } type onceChan struct { - channel chan interface{} + channel chan any wrote int32 } -func (oc *onceChan) write(val interface{}) { +func (oc *onceChan) write(val any) { if atomic.CompareAndSwapInt32(&oc.wrote, 0, 1) { oc.channel <- val } diff --git a/core/mr/mapreduce_fuzz_test.go b/core/mr/mapreduce_fuzz_test.go index fc336a95..15199808 100644 --- a/core/mr/mapreduce_fuzz_test.go +++ b/core/mr/mapreduce_fuzz_test.go @@ -29,23 +29,23 @@ func FuzzMapReduce(f *testing.F) { reducerIdx := rand.Int63n(n) squareSum := (n - 1) * n * (2*n - 1) / 6 - fn := func() (interface{}, error) { + fn := func() (any, error) { defer goleak.VerifyNone(t, goleak.IgnoreCurrent()) - return MapReduce(func(source chan<- interface{}) { + return MapReduce(func(source chan<- any) { for i := int64(0); i < n; i++ { source <- i if genPanic && i == genIdx { panic("foo") } } - }, func(item interface{}, writer Writer, cancel func(error)) { + }, func(item any, writer Writer, cancel func(error)) { v := item.(int64) if mapperPanic && v == mapperIdx { panic("bar") } writer.Write(v * v) - }, func(pipe <-chan interface{}, writer Writer, cancel func(error)) { + }, func(pipe <-chan any, writer Writer, cancel func(error)) { var idx int64 var total int64 for v := range pipe { diff --git a/core/mr/mapreduce_fuzzcase_test.go b/core/mr/mapreduce_fuzzcase_test.go index cbc8fc29..39b3ab39 100644 --- a/core/mr/mapreduce_fuzzcase_test.go +++ b/core/mr/mapreduce_fuzzcase_test.go @@ -54,21 +54,21 @@ func TestMapReduceRandom(t *testing.T) { reducerIdx := rand.Int63n(n) squareSum := (n - 1) * n * (2*n - 1) / 6 - fn := func() (interface{}, error) { - return MapReduce(func(source chan<- interface{}) { + fn := func() (any, error) { + return MapReduce(func(source chan<- any) { for i := int64(0); i < n; i++ { source <- i if genPanic && i == genIdx { panic("foo") } } - }, func(item interface{}, writer Writer, cancel func(error)) { + }, func(item any, writer Writer, cancel func(error)) { v := item.(int64) if mapperPanic && v == mapperIdx { panic("bar") } writer.Write(v * v) - }, func(pipe <-chan interface{}, writer Writer, cancel func(error)) { + }, func(pipe <-chan any, writer Writer, cancel func(error)) { var idx int64 var total int64 for v := range pipe { diff --git a/core/mr/mapreduce_test.go b/core/mr/mapreduce_test.go index c2b37796..79030fc7 100644 --- a/core/mr/mapreduce_test.go +++ b/core/mr/mapreduce_test.go @@ -91,11 +91,11 @@ func TestForEach(t *testing.T) { defer goleak.VerifyNone(t) var count uint32 - ForEach(func(source chan<- interface{}) { + ForEach(func(source chan<- any) { for i := 0; i < tasks; i++ { source <- i } - }, func(item interface{}) { + }, func(item any) { atomic.AddUint32(&count, 1) }, WithWorkers(-1)) @@ -106,11 +106,11 @@ func TestForEach(t *testing.T) { defer goleak.VerifyNone(t) var count uint32 - ForEach(func(source chan<- interface{}) { + ForEach(func(source chan<- any) { for i := 0; i < tasks; i++ { source <- i } - }, func(item interface{}) { + }, func(item any) { if item.(int)%2 == 0 { atomic.AddUint32(&count, 1) } @@ -123,11 +123,11 @@ func TestForEach(t *testing.T) { defer goleak.VerifyNone(t) assert.PanicsWithValue(t, "foo", func() { - ForEach(func(source chan<- interface{}) { + ForEach(func(source chan<- any) { for i := 0; i < tasks; i++ { source <- i } - }, func(item interface{}) { + }, func(item any) { panic("foo") }) }) @@ -139,9 +139,9 @@ func TestGeneratePanic(t *testing.T) { t.Run("all", func(t *testing.T) { assert.PanicsWithValue(t, "foo", func() { - ForEach(func(source chan<- interface{}) { + ForEach(func(source chan<- any) { panic("foo") - }, func(item interface{}) { + }, func(item any) { }) }) }) @@ -154,14 +154,14 @@ func TestMapperPanic(t *testing.T) { var run int32 t.Run("all", func(t *testing.T) { assert.PanicsWithValue(t, "foo", func() { - _, _ = MapReduce(func(source chan<- interface{}) { + _, _ = MapReduce(func(source chan<- any) { for i := 0; i < tasks; i++ { source <- i } - }, func(item interface{}, writer Writer, cancel func(error)) { + }, func(item any, writer Writer, cancel func(error)) { atomic.AddInt32(&run, 1) panic("foo") - }, func(pipe <-chan interface{}, writer Writer, cancel func(error)) { + }, func(pipe <-chan any, writer Writer, cancel func(error)) { }) }) assert.True(t, atomic.LoadInt32(&run) < tasks/2) @@ -176,7 +176,7 @@ func TestMapReduce(t *testing.T) { mapper MapperFunc reducer ReducerFunc expectErr error - expectValue interface{} + expectValue any }{ { name: "simple", @@ -185,7 +185,7 @@ func TestMapReduce(t *testing.T) { }, { name: "cancel with error", - mapper: func(item interface{}, writer Writer, cancel func(error)) { + mapper: func(item any, writer Writer, cancel func(error)) { v := item.(int) if v%3 == 0 { cancel(errDummy) @@ -196,7 +196,7 @@ func TestMapReduce(t *testing.T) { }, { name: "cancel with nil", - mapper: func(item interface{}, writer Writer, cancel func(error)) { + mapper: func(item any, writer Writer, cancel func(error)) { v := item.(int) if v%3 == 0 { cancel(nil) @@ -208,7 +208,7 @@ func TestMapReduce(t *testing.T) { }, { name: "cancel with more", - reducer: func(pipe <-chan interface{}, writer Writer, cancel func(error)) { + reducer: func(pipe <-chan any, writer Writer, cancel func(error)) { var result int for item := range pipe { result += item.(int) @@ -226,13 +226,13 @@ func TestMapReduce(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { if test.mapper == nil { - test.mapper = func(item interface{}, writer Writer, cancel func(error)) { + test.mapper = func(item any, writer Writer, cancel func(error)) { v := item.(int) writer.Write(v * v) } } if test.reducer == nil { - test.reducer = func(pipe <-chan interface{}, writer Writer, cancel func(error)) { + test.reducer = func(pipe <-chan any, writer Writer, cancel func(error)) { var result int for item := range pipe { result += item.(int) @@ -240,7 +240,7 @@ func TestMapReduce(t *testing.T) { writer.Write(result) } } - value, err := MapReduce(func(source chan<- interface{}) { + value, err := MapReduce(func(source chan<- any) { for i := 1; i < 5; i++ { source <- i } @@ -256,13 +256,13 @@ func TestMapReduce(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { if test.mapper == nil { - test.mapper = func(item interface{}, writer Writer, cancel func(error)) { + test.mapper = func(item any, writer Writer, cancel func(error)) { v := item.(int) writer.Write(v * v) } } if test.reducer == nil { - test.reducer = func(pipe <-chan interface{}, writer Writer, cancel func(error)) { + test.reducer = func(pipe <-chan any, writer Writer, cancel func(error)) { var result int for item := range pipe { result += item.(int) @@ -271,7 +271,7 @@ func TestMapReduce(t *testing.T) { } } - source := make(chan interface{}) + source := make(chan any) go func() { for i := 1; i < 5; i++ { source <- i @@ -291,13 +291,13 @@ func TestMapReduceWithReduerWriteMoreThanOnce(t *testing.T) { defer goleak.VerifyNone(t) assert.Panics(t, func() { - MapReduce(func(source chan<- interface{}) { + MapReduce(func(source chan<- any) { for i := 0; i < 10; i++ { source <- i } - }, func(item interface{}, writer Writer, cancel func(error)) { + }, func(item any, writer Writer, cancel func(error)) { writer.Write(item) - }, func(pipe <-chan interface{}, writer Writer, cancel func(error)) { + }, func(pipe <-chan any, writer Writer, cancel func(error)) { drain(pipe) writer.Write("one") writer.Write("two") @@ -323,7 +323,7 @@ func TestMapReduceVoid(t *testing.T) { }, { name: "cancel with error", - mapper: func(item interface{}, writer Writer, cancel func(error)) { + mapper: func(item any, writer Writer, cancel func(error)) { v := item.(int) if v%3 == 0 { cancel(errDummy) @@ -334,7 +334,7 @@ func TestMapReduceVoid(t *testing.T) { }, { name: "cancel with nil", - mapper: func(item interface{}, writer Writer, cancel func(error)) { + mapper: func(item any, writer Writer, cancel func(error)) { v := item.(int) if v%3 == 0 { cancel(nil) @@ -345,7 +345,7 @@ func TestMapReduceVoid(t *testing.T) { }, { name: "cancel with more", - reducer: func(pipe <-chan interface{}, cancel func(error)) { + reducer: func(pipe <-chan any, cancel func(error)) { for item := range pipe { result := atomic.AddUint32(&value, uint32(item.(int))) if result > 10 { @@ -362,19 +362,19 @@ func TestMapReduceVoid(t *testing.T) { atomic.StoreUint32(&value, 0) if test.mapper == nil { - test.mapper = func(item interface{}, writer Writer, cancel func(error)) { + test.mapper = func(item any, writer Writer, cancel func(error)) { v := item.(int) writer.Write(v * v) } } if test.reducer == nil { - test.reducer = func(pipe <-chan interface{}, cancel func(error)) { + test.reducer = func(pipe <-chan any, cancel func(error)) { for item := range pipe { atomic.AddUint32(&value, uint32(item.(int))) } } } - err := MapReduceVoid(func(source chan<- interface{}) { + err := MapReduceVoid(func(source chan<- any) { for i := 1; i < 5; i++ { source <- i } @@ -392,16 +392,16 @@ func TestMapReduceVoidWithDelay(t *testing.T) { defer goleak.VerifyNone(t) var result []int - err := MapReduceVoid(func(source chan<- interface{}) { + err := MapReduceVoid(func(source chan<- any) { source <- 0 source <- 1 - }, func(item interface{}, writer Writer, cancel func(error)) { + }, func(item any, writer Writer, cancel func(error)) { i := item.(int) if i == 0 { time.Sleep(time.Millisecond * 50) } writer.Write(i) - }, func(pipe <-chan interface{}, cancel func(error)) { + }, func(pipe <-chan any, cancel func(error)) { for item := range pipe { i := item.(int) result = append(result, i) @@ -417,13 +417,13 @@ func TestMapReducePanic(t *testing.T) { defer goleak.VerifyNone(t) assert.Panics(t, func() { - _, _ = MapReduce(func(source chan<- interface{}) { + _, _ = MapReduce(func(source chan<- any) { source <- 0 source <- 1 - }, func(item interface{}, writer Writer, cancel func(error)) { + }, func(item any, writer Writer, cancel func(error)) { i := item.(int) writer.Write(i) - }, func(pipe <-chan interface{}, writer Writer, cancel func(error)) { + }, func(pipe <-chan any, writer Writer, cancel func(error)) { for range pipe { panic("panic") } @@ -435,17 +435,17 @@ func TestMapReducePanicOnce(t *testing.T) { defer goleak.VerifyNone(t) assert.Panics(t, func() { - _, _ = MapReduce(func(source chan<- interface{}) { + _, _ = MapReduce(func(source chan<- any) { for i := 0; i < 100; i++ { source <- i } - }, func(item interface{}, writer Writer, cancel func(error)) { + }, func(item any, writer Writer, cancel func(error)) { i := item.(int) if i == 0 { panic("foo") } writer.Write(i) - }, func(pipe <-chan interface{}, writer Writer, cancel func(error)) { + }, func(pipe <-chan any, writer Writer, cancel func(error)) { for range pipe { panic("bar") } @@ -457,12 +457,12 @@ func TestMapReducePanicBothMapperAndReducer(t *testing.T) { defer goleak.VerifyNone(t) assert.Panics(t, func() { - _, _ = MapReduce(func(source chan<- interface{}) { + _, _ = MapReduce(func(source chan<- any) { source <- 0 source <- 1 - }, func(item interface{}, writer Writer, cancel func(error)) { + }, func(item any, writer Writer, cancel func(error)) { panic("foo") - }, func(pipe <-chan interface{}, writer Writer, cancel func(error)) { + }, func(pipe <-chan any, writer Writer, cancel func(error)) { panic("bar") }) }) @@ -472,16 +472,16 @@ func TestMapReduceVoidCancel(t *testing.T) { defer goleak.VerifyNone(t) var result []int - err := MapReduceVoid(func(source chan<- interface{}) { + err := MapReduceVoid(func(source chan<- any) { source <- 0 source <- 1 - }, func(item interface{}, writer Writer, cancel func(error)) { + }, func(item any, writer Writer, cancel func(error)) { i := item.(int) if i == 1 { cancel(errors.New("anything")) } writer.Write(i) - }, func(pipe <-chan interface{}, cancel func(error)) { + }, func(pipe <-chan any, cancel func(error)) { for item := range pipe { i := item.(int) result = append(result, i) @@ -496,18 +496,18 @@ func TestMapReduceVoidCancelWithRemains(t *testing.T) { var done int32 var result []int - err := MapReduceVoid(func(source chan<- interface{}) { + err := MapReduceVoid(func(source chan<- any) { for i := 0; i < defaultWorkers*2; i++ { source <- i } atomic.AddInt32(&done, 1) - }, func(item interface{}, writer Writer, cancel func(error)) { + }, func(item any, writer Writer, cancel func(error)) { i := item.(int) if i == defaultWorkers/2 { cancel(errors.New("anything")) } writer.Write(i) - }, func(pipe <-chan interface{}, cancel func(error)) { + }, func(pipe <-chan any, cancel func(error)) { for item := range pipe { i := item.(int) result = append(result, i) @@ -522,13 +522,13 @@ func TestMapReduceWithoutReducerWrite(t *testing.T) { defer goleak.VerifyNone(t) uids := []int{1, 2, 3} - res, err := MapReduce(func(source chan<- interface{}) { + res, err := MapReduce(func(source chan<- any) { for _, uid := range uids { source <- uid } - }, func(item interface{}, writer Writer, cancel func(error)) { + }, func(item any, writer Writer, cancel func(error)) { writer.Write(item) - }, func(pipe <-chan interface{}, writer Writer, cancel func(error)) { + }, func(pipe <-chan any, writer Writer, cancel func(error)) { drain(pipe) // not calling writer.Write(...), should not panic }) @@ -542,15 +542,15 @@ func TestMapReduceVoidPanicInReducer(t *testing.T) { const message = "foo" assert.Panics(t, func() { var done int32 - _ = MapReduceVoid(func(source chan<- interface{}) { + _ = MapReduceVoid(func(source chan<- any) { for i := 0; i < defaultWorkers*2; i++ { source <- i } atomic.AddInt32(&done, 1) - }, func(item interface{}, writer Writer, cancel func(error)) { + }, func(item any, writer Writer, cancel func(error)) { i := item.(int) writer.Write(i) - }, func(pipe <-chan interface{}, cancel func(error)) { + }, func(pipe <-chan any, cancel func(error)) { panic(message) }, WithWorkers(1)) }) @@ -561,12 +561,12 @@ func TestForEachWithContext(t *testing.T) { var done int32 ctx, cancel := context.WithCancel(context.Background()) - ForEach(func(source chan<- interface{}) { + ForEach(func(source chan<- any) { for i := 0; i < defaultWorkers*2; i++ { source <- i } atomic.AddInt32(&done, 1) - }, func(item interface{}) { + }, func(item any) { i := item.(int) if i == defaultWorkers/2 { cancel() @@ -580,18 +580,18 @@ func TestMapReduceWithContext(t *testing.T) { var done int32 var result []int ctx, cancel := context.WithCancel(context.Background()) - err := MapReduceVoid(func(source chan<- interface{}) { + err := MapReduceVoid(func(source chan<- any) { for i := 0; i < defaultWorkers*2; i++ { source <- i } atomic.AddInt32(&done, 1) - }, func(item interface{}, writer Writer, c func(error)) { + }, func(item any, writer Writer, c func(error)) { i := item.(int) if i == defaultWorkers/2 { cancel() } writer.Write(i) - }, func(pipe <-chan interface{}, cancel func(error)) { + }, func(pipe <-chan any, cancel func(error)) { for item := range pipe { i := item.(int) result = append(result, i) @@ -604,10 +604,10 @@ func TestMapReduceWithContext(t *testing.T) { func BenchmarkMapReduce(b *testing.B) { b.ReportAllocs() - mapper := func(v interface{}, writer Writer, cancel func(error)) { + mapper := func(v any, writer Writer, cancel func(error)) { writer.Write(v.(int64) * v.(int64)) } - reducer := func(input <-chan interface{}, writer Writer, cancel func(error)) { + reducer := func(input <-chan any, writer Writer, cancel func(error)) { var result int64 for v := range input { result += v.(int64) @@ -616,7 +616,7 @@ func BenchmarkMapReduce(b *testing.B) { } for i := 0; i < b.N; i++ { - MapReduce(func(input chan<- interface{}) { + MapReduce(func(input chan<- any) { for j := 0; j < 2; j++ { input <- int64(j) } diff --git a/core/mr/readme-cn.md b/core/mr/readme-cn.md index fda1f1e9..888868ca 100644 --- a/core/mr/readme-cn.md +++ b/core/mr/readme-cn.md @@ -58,16 +58,16 @@ import ( ) func main() { - val, err := mr.MapReduce(func(source chan<- interface{}) { + val, err := mr.MapReduce(func(source chan<- any) { // generator for i := 0; i < 10; i++ { source <- i } - }, func(item interface{}, writer mr.Writer, cancel func(error)) { + }, func(item any, writer mr.Writer, cancel func(error)) { // mapper i := item.(int) writer.Write(i * i) - }, func(pipe <-chan interface{}, writer mr.Writer, cancel func(error)) { + }, func(pipe <-chan any, writer mr.Writer, cancel func(error)) { // reducer var sum int for i := range pipe { diff --git a/core/mr/readme.md b/core/mr/readme.md index e082494b..ba719a6c 100644 --- a/core/mr/readme.md +++ b/core/mr/readme.md @@ -59,16 +59,16 @@ import ( ) func main() { - val, err := mr.MapReduce(func(source chan<- interface{}) { + val, err := mr.MapReduce(func(source chan<- any) { // generator for i := 0; i < 10; i++ { source <- i } - }, func(item interface{}, writer mr.Writer, cancel func(error)) { + }, func(item any, writer mr.Writer, cancel func(error)) { // mapper i := item.(int) writer.Write(i * i) - }, func(pipe <-chan interface{}, writer mr.Writer, cancel func(error)) { + }, func(pipe <-chan any, writer mr.Writer, cancel func(error)) { // reducer var sum int for i := range pipe { diff --git a/core/queue/consumer.go b/core/queue/consumer.go index 56f07661..9986eb53 100644 --- a/core/queue/consumer.go +++ b/core/queue/consumer.go @@ -4,7 +4,7 @@ type ( // A Consumer interface represents a consumer that can consume string messages. Consumer interface { Consume(string) error - OnEvent(event interface{}) + OnEvent(event any) } // ConsumerFactory defines the factory to generate consumers. diff --git a/core/queue/queue.go b/core/queue/queue.go index 4f7817d2..81aaaae4 100644 --- a/core/queue/queue.go +++ b/core/queue/queue.go @@ -31,7 +31,7 @@ type ( quit chan struct{} listeners []Listener eventLock sync.Mutex - eventChannels []chan interface{} + eventChannels []chan any } // A Listener interface represents a listener that can be notified with queue events. @@ -77,7 +77,7 @@ func (q *Queue) AddListener(listener Listener) { } // Broadcast broadcasts message to all event channels. -func (q *Queue) Broadcast(message interface{}) { +func (q *Queue) Broadcast(message any) { go func() { q.eventLock.Lock() defer q.eventLock.Unlock() @@ -119,7 +119,7 @@ func (q *Queue) Stop() { close(q.quit) } -func (q *Queue) consume(eventChan chan interface{}) { +func (q *Queue) consume(eventChan chan any) { var consumer Consumer for { @@ -216,7 +216,7 @@ func (q *Queue) resume() { func (q *Queue) startConsumers(number int) { for i := 0; i < number; i++ { - eventChan := make(chan interface{}) + eventChan := make(chan any) q.eventLock.Lock() q.eventChannels = append(q.eventChannels, eventChan) q.eventLock.Unlock() diff --git a/core/queue/queue_test.go b/core/queue/queue_test.go index 06ba3c0b..5e5dd96a 100644 --- a/core/queue/queue_test.go +++ b/core/queue/queue_test.go @@ -52,7 +52,7 @@ func (c *mockedConsumer) Consume(string) error { return nil } -func (c *mockedConsumer) OnEvent(interface{}) { +func (c *mockedConsumer) OnEvent(any) { if atomic.AddInt32(&c.events, 1) <= consumers { c.wait.Done() } diff --git a/core/search/tree.go b/core/search/tree.go index a07e24d6..34741077 100644 --- a/core/search/tree.go +++ b/core/search/tree.go @@ -35,7 +35,7 @@ type ( } node struct { - item interface{} + item any children [2]map[string]*node } @@ -46,7 +46,7 @@ type ( // A Result is a search result from tree. Result struct { - Item interface{} + Item any Params map[string]string } ) @@ -59,7 +59,7 @@ func NewTree() *Tree { } // Add adds item to associate with route. -func (t *Tree) Add(route string, item interface{}) error { +func (t *Tree) Add(route string, item any) error { if len(route) == 0 || route[0] != slash { return errNotFromRoot } @@ -149,7 +149,7 @@ func (nd *node) getChildren(route string) map[string]*node { return nd.children[0] } -func add(nd *node, route string, item interface{}) error { +func add(nd *node, route string, item any) error { if len(route) == 0 { if nd.item != nil { return errDupItem @@ -228,7 +228,7 @@ func match(pat, token string) innerResult { } } -func newNode(item interface{}) *node { +func newNode(item any) *node { return &node{ item: item, children: [2]map[string]*node{ diff --git a/core/stat/metrics.go b/core/stat/metrics.go index e565268a..f0efe1e9 100644 --- a/core/stat/metrics.go +++ b/core/stat/metrics.go @@ -104,7 +104,7 @@ type ( } ) -func (c *metricsContainer) AddTask(v interface{}) bool { +func (c *metricsContainer) AddTask(v any) bool { if task, ok := v.(Task); ok { if task.Drop { c.drops++ @@ -117,7 +117,7 @@ func (c *metricsContainer) AddTask(v interface{}) bool { return false } -func (c *metricsContainer) Execute(v interface{}) { +func (c *metricsContainer) Execute(v any) { pair := v.(tasksDurationPair) tasks := pair.tasks duration := pair.duration @@ -180,7 +180,7 @@ func (c *metricsContainer) Execute(v interface{}) { log(report) } -func (c *metricsContainer) RemoveAll() interface{} { +func (c *metricsContainer) RemoveAll() any { tasks := c.tasks duration := c.duration drops := c.drops diff --git a/core/stat/topk.go b/core/stat/topk.go index 6457960d..d2e6a8b7 100644 --- a/core/stat/topk.go +++ b/core/stat/topk.go @@ -16,11 +16,11 @@ func (h *taskHeap) Swap(i, j int) { (*h)[i], (*h)[j] = (*h)[j], (*h)[i] } -func (h *taskHeap) Push(x interface{}) { +func (h *taskHeap) Push(x any) { *h = append(*h, x.(Task)) } -func (h *taskHeap) Pop() interface{} { +func (h *taskHeap) Pop() any { old := *h n := len(old) x := old[n-1] diff --git a/core/stores/builder/builder.go b/core/stores/builder/builder.go index 828d1ec0..feee6874 100644 --- a/core/stores/builder/builder.go +++ b/core/stores/builder/builder.go @@ -9,7 +9,7 @@ import ( const dbTag = "db" // RawFieldNames converts golang struct field into slice string. -func RawFieldNames(in interface{}, postgresSql ...bool) []string { +func RawFieldNames(in any, postgresSql ...bool) []string { out := make([]string, 0) v := reflect.ValueOf(in) if v.Kind() == reflect.Ptr { diff --git a/core/stores/cache/cache.go b/core/stores/cache/cache.go index 05346e83..d9b30b7f 100644 --- a/core/stores/cache/cache.go +++ b/core/stores/cache/cache.go @@ -20,32 +20,32 @@ type ( // DelCtx deletes cached values with keys. DelCtx(ctx context.Context, keys ...string) error // Get gets the cache with key and fills into v. - Get(key string, val interface{}) error + Get(key string, val any) error // GetCtx gets the cache with key and fills into v. - GetCtx(ctx context.Context, key string, val interface{}) error + GetCtx(ctx context.Context, key string, val any) error // IsNotFound checks if the given error is the defined errNotFound. IsNotFound(err error) bool // Set sets the cache with key and v, using c.expiry. - Set(key string, val interface{}) error + Set(key string, val any) error // SetCtx sets the cache with key and v, using c.expiry. - SetCtx(ctx context.Context, key string, val interface{}) error + SetCtx(ctx context.Context, key string, val any) error // SetWithExpire sets the cache with key and v, using given expire. - SetWithExpire(key string, val interface{}, expire time.Duration) error + SetWithExpire(key string, val any, expire time.Duration) error // SetWithExpireCtx sets the cache with key and v, using given expire. - SetWithExpireCtx(ctx context.Context, key string, val interface{}, expire time.Duration) error + SetWithExpireCtx(ctx context.Context, key string, val any, expire time.Duration) error // Take takes the result from cache first, if not found, // query from DB and set cache using c.expiry, then return the result. - Take(val interface{}, key string, query func(val interface{}) error) error + Take(val any, key string, query func(val any) error) error // TakeCtx takes the result from cache first, if not found, // query from DB and set cache using c.expiry, then return the result. - TakeCtx(ctx context.Context, val interface{}, key string, query func(val interface{}) error) error + TakeCtx(ctx context.Context, val any, key string, query func(val any) error) error // TakeWithExpire takes the result from cache first, if not found, // query from DB and set cache using given expire, then return the result. - TakeWithExpire(val interface{}, key string, query func(val interface{}, expire time.Duration) error) error + TakeWithExpire(val any, key string, query func(val any, expire time.Duration) error) error // TakeWithExpireCtx takes the result from cache first, if not found, // query from DB and set cache using given expire, then return the result. - TakeWithExpireCtx(ctx context.Context, val interface{}, key string, - query func(val interface{}, expire time.Duration) error) error + TakeWithExpireCtx(ctx context.Context, val any, key string, + query func(val any, expire time.Duration) error) error } cacheCluster struct { @@ -97,7 +97,7 @@ func (cc cacheCluster) DelCtx(ctx context.Context, keys ...string) error { return c.(Cache).DelCtx(ctx, key) default: var be errorx.BatchError - nodes := make(map[interface{}][]string) + nodes := make(map[any][]string) for _, key := range keys { c, ok := cc.dispatcher.Get(key) if !ok { @@ -118,12 +118,12 @@ func (cc cacheCluster) DelCtx(ctx context.Context, keys ...string) error { } // Get gets the cache with key and fills into v. -func (cc cacheCluster) Get(key string, val interface{}) error { +func (cc cacheCluster) Get(key string, val any) error { return cc.GetCtx(context.Background(), key, val) } // GetCtx gets the cache with key and fills into v. -func (cc cacheCluster) GetCtx(ctx context.Context, key string, val interface{}) error { +func (cc cacheCluster) GetCtx(ctx context.Context, key string, val any) error { c, ok := cc.dispatcher.Get(key) if !ok { return cc.errNotFound @@ -138,12 +138,12 @@ func (cc cacheCluster) IsNotFound(err error) bool { } // Set sets the cache with key and v, using c.expiry. -func (cc cacheCluster) Set(key string, val interface{}) error { +func (cc cacheCluster) Set(key string, val any) error { return cc.SetCtx(context.Background(), key, val) } // SetCtx sets the cache with key and v, using c.expiry. -func (cc cacheCluster) SetCtx(ctx context.Context, key string, val interface{}) error { +func (cc cacheCluster) SetCtx(ctx context.Context, key string, val any) error { c, ok := cc.dispatcher.Get(key) if !ok { return cc.errNotFound @@ -153,12 +153,12 @@ func (cc cacheCluster) SetCtx(ctx context.Context, key string, val interface{}) } // SetWithExpire sets the cache with key and v, using given expire. -func (cc cacheCluster) SetWithExpire(key string, val interface{}, expire time.Duration) error { +func (cc cacheCluster) SetWithExpire(key string, val any, expire time.Duration) error { return cc.SetWithExpireCtx(context.Background(), key, val, expire) } // SetWithExpireCtx sets the cache with key and v, using given expire. -func (cc cacheCluster) SetWithExpireCtx(ctx context.Context, key string, val interface{}, expire time.Duration) error { +func (cc cacheCluster) SetWithExpireCtx(ctx context.Context, key string, val any, expire time.Duration) error { c, ok := cc.dispatcher.Get(key) if !ok { return cc.errNotFound @@ -169,13 +169,13 @@ func (cc cacheCluster) SetWithExpireCtx(ctx context.Context, key string, val int // Take takes the result from cache first, if not found, // query from DB and set cache using c.expiry, then return the result. -func (cc cacheCluster) Take(val interface{}, key string, query func(val interface{}) error) error { +func (cc cacheCluster) Take(val any, key string, query func(val any) error) error { return cc.TakeCtx(context.Background(), val, key, query) } // TakeCtx takes the result from cache first, if not found, // query from DB and set cache using c.expiry, then return the result. -func (cc cacheCluster) TakeCtx(ctx context.Context, val interface{}, key string, query func(val interface{}) error) error { +func (cc cacheCluster) TakeCtx(ctx context.Context, val any, key string, query func(val any) error) error { c, ok := cc.dispatcher.Get(key) if !ok { return cc.errNotFound @@ -186,13 +186,13 @@ func (cc cacheCluster) TakeCtx(ctx context.Context, val interface{}, key string, // TakeWithExpire takes the result from cache first, if not found, // query from DB and set cache using given expire, then return the result. -func (cc cacheCluster) TakeWithExpire(val interface{}, key string, query func(val interface{}, expire time.Duration) error) error { +func (cc cacheCluster) TakeWithExpire(val any, key string, query func(val any, expire time.Duration) error) error { return cc.TakeWithExpireCtx(context.Background(), val, key, query) } // TakeWithExpireCtx takes the result from cache first, if not found, // query from DB and set cache using given expire, then return the result. -func (cc cacheCluster) TakeWithExpireCtx(ctx context.Context, val interface{}, key string, query func(val interface{}, expire time.Duration) error) error { +func (cc cacheCluster) TakeWithExpireCtx(ctx context.Context, val any, key string, query func(val any, expire time.Duration) error) error { c, ok := cc.dispatcher.Get(key) if !ok { return cc.errNotFound diff --git a/core/stores/cache/cache_test.go b/core/stores/cache/cache_test.go index 9c5b843a..83912492 100644 --- a/core/stores/cache/cache_test.go +++ b/core/stores/cache/cache_test.go @@ -44,11 +44,11 @@ func (mc *mockedNode) DelCtx(_ context.Context, keys ...string) error { return be.Err() } -func (mc *mockedNode) Get(key string, val interface{}) error { +func (mc *mockedNode) Get(key string, val any) error { return mc.GetCtx(context.Background(), key, val) } -func (mc *mockedNode) GetCtx(ctx context.Context, key string, val interface{}) error { +func (mc *mockedNode) GetCtx(ctx context.Context, key string, val any) error { bs, ok := mc.vals[key] if ok { return json.Unmarshal(bs, val) @@ -61,11 +61,11 @@ func (mc *mockedNode) IsNotFound(err error) bool { return errors.Is(err, mc.errNotFound) } -func (mc *mockedNode) Set(key string, val interface{}) error { +func (mc *mockedNode) Set(key string, val any) error { return mc.SetCtx(context.Background(), key, val) } -func (mc *mockedNode) SetCtx(ctx context.Context, key string, val interface{}) error { +func (mc *mockedNode) SetCtx(ctx context.Context, key string, val any) error { data, err := json.Marshal(val) if err != nil { return err @@ -75,19 +75,19 @@ func (mc *mockedNode) SetCtx(ctx context.Context, key string, val interface{}) e return nil } -func (mc *mockedNode) SetWithExpire(key string, val interface{}, expire time.Duration) error { +func (mc *mockedNode) SetWithExpire(key string, val any, expire time.Duration) error { return mc.SetWithExpireCtx(context.Background(), key, val, expire) } -func (mc *mockedNode) SetWithExpireCtx(ctx context.Context, key string, val interface{}, expire time.Duration) error { +func (mc *mockedNode) SetWithExpireCtx(ctx context.Context, key string, val any, expire time.Duration) error { return mc.Set(key, val) } -func (mc *mockedNode) Take(val interface{}, key string, query func(val interface{}) error) error { +func (mc *mockedNode) Take(val any, key string, query func(val any) error) error { return mc.TakeCtx(context.Background(), val, key, query) } -func (mc *mockedNode) TakeCtx(ctx context.Context, val interface{}, key string, query func(val interface{}) error) error { +func (mc *mockedNode) TakeCtx(ctx context.Context, val any, key string, query func(val any) error) error { if _, ok := mc.vals[key]; ok { return mc.GetCtx(ctx, key, val) } @@ -99,12 +99,12 @@ func (mc *mockedNode) TakeCtx(ctx context.Context, val interface{}, key string, return mc.SetCtx(ctx, key, val) } -func (mc *mockedNode) TakeWithExpire(val interface{}, key string, query func(val interface{}, expire time.Duration) error) error { +func (mc *mockedNode) TakeWithExpire(val any, key string, query func(val any, expire time.Duration) error) error { return mc.TakeWithExpireCtx(context.Background(), val, key, query) } -func (mc *mockedNode) TakeWithExpireCtx(ctx context.Context, val interface{}, key string, query func(val interface{}, expire time.Duration) error) error { - return mc.Take(val, key, func(val interface{}) error { +func (mc *mockedNode) TakeWithExpireCtx(ctx context.Context, val any, key string, query func(val any, expire time.Duration) error) error { + return mc.Take(val, key, func(val any) error { return query(val, 0) }) } @@ -279,13 +279,13 @@ func TestCache_Balance(t *testing.T) { for i := 0; i < total/10; i++ { var val int if i%2 == 0 { - assert.Nil(t, c.Take(&val, strconv.Itoa(i*10), func(val interface{}) error { + assert.Nil(t, c.Take(&val, strconv.Itoa(i*10), func(val any) error { *val.(*int) = i count++ return nil })) } else { - assert.Nil(t, c.TakeWithExpire(&val, strconv.Itoa(i*10), func(val interface{}, expire time.Duration) error { + assert.Nil(t, c.TakeWithExpire(&val, strconv.Itoa(i*10), func(val any, expire time.Duration) error { *val.(*int) = i count++ return nil @@ -307,10 +307,10 @@ func TestCacheNoNode(t *testing.T) { assert.NotNil(t, c.Get("foo", nil)) assert.NotNil(t, c.Set("foo", nil)) assert.NotNil(t, c.SetWithExpire("foo", nil, time.Second)) - assert.NotNil(t, c.Take(nil, "foo", func(val interface{}) error { + assert.NotNil(t, c.Take(nil, "foo", func(val any) error { return nil })) - assert.NotNil(t, c.TakeWithExpire(nil, "foo", func(val interface{}, duration time.Duration) error { + assert.NotNil(t, c.TakeWithExpire(nil, "foo", func(val any, duration time.Duration) error { return nil })) } diff --git a/core/stores/cache/cachenode.go b/core/stores/cache/cachenode.go index 1baae63b..43d1c478 100644 --- a/core/stores/cache/cachenode.go +++ b/core/stores/cache/cachenode.go @@ -89,12 +89,12 @@ func (c cacheNode) DelCtx(ctx context.Context, keys ...string) error { } // Get gets the cache with key and fills into v. -func (c cacheNode) Get(key string, val interface{}) error { +func (c cacheNode) Get(key string, val any) error { return c.GetCtx(context.Background(), key, val) } // GetCtx gets the cache with key and fills into v. -func (c cacheNode) GetCtx(ctx context.Context, key string, val interface{}) error { +func (c cacheNode) GetCtx(ctx context.Context, key string, val any) error { err := c.doGetCache(ctx, key, val) if err == errPlaceholder { return c.errNotFound @@ -109,22 +109,22 @@ func (c cacheNode) IsNotFound(err error) bool { } // Set sets the cache with key and v, using c.expiry. -func (c cacheNode) Set(key string, val interface{}) error { +func (c cacheNode) Set(key string, val any) error { return c.SetCtx(context.Background(), key, val) } // SetCtx sets the cache with key and v, using c.expiry. -func (c cacheNode) SetCtx(ctx context.Context, key string, val interface{}) error { +func (c cacheNode) SetCtx(ctx context.Context, key string, val any) error { return c.SetWithExpireCtx(ctx, key, val, c.aroundDuration(c.expiry)) } // SetWithExpire sets the cache with key and v, using given expire. -func (c cacheNode) SetWithExpire(key string, val interface{}, expire time.Duration) error { +func (c cacheNode) SetWithExpire(key string, val any, expire time.Duration) error { return c.SetWithExpireCtx(context.Background(), key, val, expire) } // SetWithExpireCtx sets the cache with key and v, using given expire. -func (c cacheNode) SetWithExpireCtx(ctx context.Context, key string, val interface{}, +func (c cacheNode) SetWithExpireCtx(ctx context.Context, key string, val any, expire time.Duration) error { data, err := jsonx.Marshal(val) if err != nil { @@ -141,34 +141,34 @@ func (c cacheNode) String() string { // Take takes the result from cache first, if not found, // query from DB and set cache using c.expiry, then return the result. -func (c cacheNode) Take(val interface{}, key string, query func(val interface{}) error) error { +func (c cacheNode) Take(val any, key string, query func(val any) error) error { return c.TakeCtx(context.Background(), val, key, query) } // TakeCtx takes the result from cache first, if not found, // query from DB and set cache using c.expiry, then return the result. -func (c cacheNode) TakeCtx(ctx context.Context, val interface{}, key string, - query func(val interface{}) error) error { - return c.doTake(ctx, val, key, query, func(v interface{}) error { +func (c cacheNode) TakeCtx(ctx context.Context, val any, key string, + query func(val any) error) error { + return c.doTake(ctx, val, key, query, func(v any) error { return c.SetCtx(ctx, key, v) }) } // TakeWithExpire takes the result from cache first, if not found, // query from DB and set cache using given expire, then return the result. -func (c cacheNode) TakeWithExpire(val interface{}, key string, query func(val interface{}, +func (c cacheNode) TakeWithExpire(val any, key string, query func(val any, expire time.Duration) error) error { return c.TakeWithExpireCtx(context.Background(), val, key, query) } // TakeWithExpireCtx takes the result from cache first, if not found, // query from DB and set cache using given expire, then return the result. -func (c cacheNode) TakeWithExpireCtx(ctx context.Context, val interface{}, key string, - query func(val interface{}, expire time.Duration) error) error { +func (c cacheNode) TakeWithExpireCtx(ctx context.Context, val any, key string, + query func(val any, expire time.Duration) error) error { expire := c.aroundDuration(c.expiry) - return c.doTake(ctx, val, key, func(v interface{}) error { + return c.doTake(ctx, val, key, func(v any) error { return query(v, expire) - }, func(v interface{}) error { + }, func(v any) error { return c.SetWithExpireCtx(ctx, key, v, expire) }) } @@ -184,7 +184,7 @@ func (c cacheNode) asyncRetryDelCache(keys ...string) { }, keys...) } -func (c cacheNode) doGetCache(ctx context.Context, key string, v interface{}) error { +func (c cacheNode) doGetCache(ctx context.Context, key string, v any) error { c.stat.IncrementTotal() data, err := c.rds.GetCtx(ctx, key) if err != nil { @@ -205,10 +205,10 @@ func (c cacheNode) doGetCache(ctx context.Context, key string, v interface{}) er return c.processCache(ctx, key, data, v) } -func (c cacheNode) doTake(ctx context.Context, v interface{}, key string, - query func(v interface{}) error, cacheVal func(v interface{}) error) error { +func (c cacheNode) doTake(ctx context.Context, v any, key string, + query func(v any) error, cacheVal func(v any) error) error { logger := logx.WithContext(ctx) - val, fresh, err := c.barrier.DoEx(key, func() (interface{}, error) { + val, fresh, err := c.barrier.DoEx(key, func() (any, error) { if err := c.doGetCache(ctx, key, v); err != nil { if err == errPlaceholder { return nil, c.errNotFound @@ -255,7 +255,7 @@ func (c cacheNode) doTake(ctx context.Context, v interface{}, key string, return jsonx.Unmarshal(val.([]byte), v) } -func (c cacheNode) processCache(ctx context.Context, key, data string, v interface{}) error { +func (c cacheNode) processCache(ctx context.Context, key, data string, v any) error { err := jsonx.Unmarshal([]byte(data), v) if err == nil { return nil diff --git a/core/stores/cache/cachenode_test.go b/core/stores/cache/cachenode_test.go index 3213ccbf..ab2cae06 100644 --- a/core/stores/cache/cachenode_test.go +++ b/core/stores/cache/cachenode_test.go @@ -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)) } diff --git a/core/stores/cache/cleaner.go b/core/stores/cache/cleaner.go index ce95ecc2..ce0b50a4 100644 --- a/core/stores/cache/cleaner.go +++ b/core/stores/cache/cleaner.go @@ -48,7 +48,7 @@ func AddCleanTask(task func() error, keys ...string) { }, time.Second) } -func clean(key, value interface{}) { +func clean(key, value any) { taskRunner.Schedule(func() { dt := value.(delayTask) err := dt.task() diff --git a/core/stores/kv/store.go b/core/stores/kv/store.go index fcaf07c1..ca9d113f 100644 --- a/core/stores/kv/store.go +++ b/core/stores/kv/store.go @@ -23,8 +23,8 @@ type ( DecrbyCtx(ctx context.Context, key string, decrement int64) (int64, error) Del(keys ...string) (int, error) DelCtx(ctx context.Context, keys ...string) (int, error) - Eval(script, key string, args ...interface{}) (interface{}, error) - EvalCtx(ctx context.Context, script, key string, args ...interface{}) (interface{}, error) + Eval(script, key string, args ...any) (any, error) + EvalCtx(ctx context.Context, script, key string, args ...any) (any, error) Exists(key string) (bool, error) ExistsCtx(ctx context.Context, key string) (bool, error) Expire(key string, seconds int) error @@ -69,22 +69,22 @@ type ( LlenCtx(ctx context.Context, key string) (int, error) Lpop(key string) (string, error) LpopCtx(ctx context.Context, key string) (string, error) - Lpush(key string, values ...interface{}) (int, error) - LpushCtx(ctx context.Context, key string, values ...interface{}) (int, error) + Lpush(key string, values ...any) (int, error) + LpushCtx(ctx context.Context, key string, values ...any) (int, error) Lrange(key string, start, stop int) ([]string, error) LrangeCtx(ctx context.Context, key string, start, stop int) ([]string, error) Lrem(key string, count int, value string) (int, error) LremCtx(ctx context.Context, key string, count int, value string) (int, error) Persist(key string) (bool, error) PersistCtx(ctx context.Context, key string) (bool, error) - Pfadd(key string, values ...interface{}) (bool, error) - PfaddCtx(ctx context.Context, key string, values ...interface{}) (bool, error) + Pfadd(key string, values ...any) (bool, error) + PfaddCtx(ctx context.Context, key string, values ...any) (bool, error) Pfcount(key string) (int64, error) PfcountCtx(ctx context.Context, key string) (int64, error) - Rpush(key string, values ...interface{}) (int, error) - RpushCtx(ctx context.Context, key string, values ...interface{}) (int, error) - Sadd(key string, values ...interface{}) (int, error) - SaddCtx(ctx context.Context, key string, values ...interface{}) (int, error) + Rpush(key string, values ...any) (int, error) + RpushCtx(ctx context.Context, key string, values ...any) (int, error) + Sadd(key string, values ...any) (int, error) + SaddCtx(ctx context.Context, key string, values ...any) (int, error) Scard(key string) (int64, error) ScardCtx(ctx context.Context, key string) (int64, error) Set(key, value string) error @@ -95,16 +95,16 @@ type ( SetnxCtx(ctx context.Context, key, value string) (bool, error) SetnxEx(key, value string, seconds int) (bool, error) SetnxExCtx(ctx context.Context, key, value string, seconds int) (bool, error) - Sismember(key string, value interface{}) (bool, error) - SismemberCtx(ctx context.Context, key string, value interface{}) (bool, error) + Sismember(key string, value any) (bool, error) + SismemberCtx(ctx context.Context, key string, value any) (bool, error) Smembers(key string) ([]string, error) SmembersCtx(ctx context.Context, key string) ([]string, error) Spop(key string) (string, error) SpopCtx(ctx context.Context, key string) (string, error) Srandmember(key string, count int) ([]string, error) SrandmemberCtx(ctx context.Context, key string, count int) ([]string, error) - Srem(key string, values ...interface{}) (int, error) - SremCtx(ctx context.Context, key string, values ...interface{}) (int, error) + Srem(key string, values ...any) (int, error) + SremCtx(ctx context.Context, key string, values ...any) (int, error) Sscan(key string, cursor uint64, match string, count int64) (keys []string, cur uint64, err error) SscanCtx(ctx context.Context, key string, cursor uint64, match string, count int64) (keys []string, cur uint64, err error) Ttl(key string) (int, error) @@ -131,8 +131,8 @@ type ( ZrangebyscoreWithScoresAndLimitCtx(ctx context.Context, key string, start, stop int64, page, size int) ([]redis.Pair, error) Zrank(key, field string) (int64, error) ZrankCtx(ctx context.Context, key, field string) (int64, error) - Zrem(key string, values ...interface{}) (int, error) - ZremCtx(ctx context.Context, key string, values ...interface{}) (int, error) + Zrem(key string, values ...any) (int, error) + ZremCtx(ctx context.Context, key string, values ...any) (int, error) Zremrangebyrank(key string, start, stop int64) (int, error) ZremrangebyrankCtx(ctx context.Context, key string, start, stop int64) (int, error) Zremrangebyscore(key string, start, stop int64) (int, error) @@ -224,11 +224,11 @@ func (cs clusterStore) DelCtx(ctx context.Context, keys ...string) (int, error) return val, be.Err() } -func (cs clusterStore) Eval(script, key string, args ...interface{}) (interface{}, error) { +func (cs clusterStore) Eval(script, key string, args ...any) (any, error) { return cs.EvalCtx(context.Background(), script, key, args...) } -func (cs clusterStore) EvalCtx(ctx context.Context, script, key string, args ...interface{}) (interface{}, error) { +func (cs clusterStore) EvalCtx(ctx context.Context, script, key string, args ...any) (any, error) { node, err := cs.getRedis(key) if err != nil { return nil, err @@ -510,11 +510,11 @@ func (cs clusterStore) LpopCtx(ctx context.Context, key string) (string, error) return node.LpopCtx(ctx, key) } -func (cs clusterStore) Lpush(key string, values ...interface{}) (int, error) { +func (cs clusterStore) Lpush(key string, values ...any) (int, error) { return cs.LpushCtx(context.Background(), key, values...) } -func (cs clusterStore) LpushCtx(ctx context.Context, key string, values ...interface{}) (int, error) { +func (cs clusterStore) LpushCtx(ctx context.Context, key string, values ...any) (int, error) { node, err := cs.getRedis(key) if err != nil { return 0, err @@ -562,11 +562,11 @@ func (cs clusterStore) PersistCtx(ctx context.Context, key string) (bool, error) return node.PersistCtx(ctx, key) } -func (cs clusterStore) Pfadd(key string, values ...interface{}) (bool, error) { +func (cs clusterStore) Pfadd(key string, values ...any) (bool, error) { return cs.PfaddCtx(context.Background(), key, values...) } -func (cs clusterStore) PfaddCtx(ctx context.Context, key string, values ...interface{}) (bool, error) { +func (cs clusterStore) PfaddCtx(ctx context.Context, key string, values ...any) (bool, error) { node, err := cs.getRedis(key) if err != nil { return false, err @@ -588,11 +588,11 @@ func (cs clusterStore) PfcountCtx(ctx context.Context, key string) (int64, error return node.PfcountCtx(ctx, key) } -func (cs clusterStore) Rpush(key string, values ...interface{}) (int, error) { +func (cs clusterStore) Rpush(key string, values ...any) (int, error) { return cs.RpushCtx(context.Background(), key, values...) } -func (cs clusterStore) RpushCtx(ctx context.Context, key string, values ...interface{}) (int, error) { +func (cs clusterStore) RpushCtx(ctx context.Context, key string, values ...any) (int, error) { node, err := cs.getRedis(key) if err != nil { return 0, err @@ -601,11 +601,11 @@ func (cs clusterStore) RpushCtx(ctx context.Context, key string, values ...inter return node.RpushCtx(ctx, key, values...) } -func (cs clusterStore) Sadd(key string, values ...interface{}) (int, error) { +func (cs clusterStore) Sadd(key string, values ...any) (int, error) { return cs.SaddCtx(context.Background(), key, values...) } -func (cs clusterStore) SaddCtx(ctx context.Context, key string, values ...interface{}) (int, error) { +func (cs clusterStore) SaddCtx(ctx context.Context, key string, values ...any) (int, error) { node, err := cs.getRedis(key) if err != nil { return 0, err @@ -692,11 +692,11 @@ func (cs clusterStore) GetSetCtx(ctx context.Context, key, value string) (string return node.GetSetCtx(ctx, key, value) } -func (cs clusterStore) Sismember(key string, value interface{}) (bool, error) { +func (cs clusterStore) Sismember(key string, value any) (bool, error) { return cs.SismemberCtx(context.Background(), key, value) } -func (cs clusterStore) SismemberCtx(ctx context.Context, key string, value interface{}) (bool, error) { +func (cs clusterStore) SismemberCtx(ctx context.Context, key string, value any) (bool, error) { node, err := cs.getRedis(key) if err != nil { return false, err @@ -744,11 +744,11 @@ func (cs clusterStore) SrandmemberCtx(ctx context.Context, key string, count int return node.SrandmemberCtx(ctx, key, count) } -func (cs clusterStore) Srem(key string, values ...interface{}) (int, error) { +func (cs clusterStore) Srem(key string, values ...any) (int, error) { return cs.SremCtx(context.Background(), key, values...) } -func (cs clusterStore) SremCtx(ctx context.Context, key string, values ...interface{}) (int, error) { +func (cs clusterStore) SremCtx(ctx context.Context, key string, values ...any) (int, error) { node, err := cs.getRedis(key) if err != nil { return 0, err @@ -925,11 +925,11 @@ func (cs clusterStore) ZrangebyscoreWithScoresAndLimitCtx(ctx context.Context, k return node.ZrangebyscoreWithScoresAndLimitCtx(ctx, key, start, stop, page, size) } -func (cs clusterStore) Zrem(key string, values ...interface{}) (int, error) { +func (cs clusterStore) Zrem(key string, values ...any) (int, error) { return cs.ZremCtx(context.Background(), key, values...) } -func (cs clusterStore) ZremCtx(ctx context.Context, key string, values ...interface{}) (int, error) { +func (cs clusterStore) ZremCtx(ctx context.Context, key string, values ...any) (int, error) { node, err := cs.getRedis(key) if err != nil { return 0, err diff --git a/core/stores/mon/bulkinserter.go b/core/stores/mon/bulkinserter.go index 7ef15ca5..182326ff 100644 --- a/core/stores/mon/bulkinserter.go +++ b/core/stores/mon/bulkinserter.go @@ -53,7 +53,7 @@ func (bi *BulkInserter) Flush() { } // Insert inserts doc. -func (bi *BulkInserter) Insert(doc interface{}) { +func (bi *BulkInserter) Insert(doc any) { bi.executor.Add(doc) } @@ -66,17 +66,17 @@ func (bi *BulkInserter) SetResultHandler(handler ResultHandler) { type dbInserter struct { collection *mongo.Collection - documents []interface{} + documents []any resultHandler ResultHandler } -func (in *dbInserter) AddTask(doc interface{}) bool { +func (in *dbInserter) AddTask(doc any) bool { in.documents = append(in.documents, doc) return len(in.documents) >= maxBulkRows } -func (in *dbInserter) Execute(objs interface{}) { - docs := objs.([]interface{}) +func (in *dbInserter) Execute(objs any) { + docs := objs.([]any) if len(docs) == 0 { return } @@ -89,7 +89,7 @@ func (in *dbInserter) Execute(objs interface{}) { } } -func (in *dbInserter) RemoveAll() interface{} { +func (in *dbInserter) RemoveAll() any { documents := in.documents in.documents = nil return documents diff --git a/core/stores/mon/collection.go b/core/stores/mon/collection.go index 229d83cc..1c445939 100644 --- a/core/stores/mon/collection.go +++ b/core/stores/mon/collection.go @@ -46,7 +46,7 @@ type ( // Collection defines a MongoDB collection. Collection interface { // Aggregate executes an aggregation pipeline. - Aggregate(ctx context.Context, pipeline interface{}, opts ...*mopt.AggregateOptions) ( + Aggregate(ctx context.Context, pipeline any, opts ...*mopt.AggregateOptions) ( *mongo.Cursor, error) // BulkWrite performs a bulk write operation. BulkWrite(ctx context.Context, models []mongo.WriteModel, opts ...*mopt.BulkWriteOptions) ( @@ -54,64 +54,64 @@ type ( // Clone creates a copy of this collection with the same settings. Clone(opts ...*mopt.CollectionOptions) (*mongo.Collection, error) // CountDocuments returns the number of documents in the collection that match the filter. - CountDocuments(ctx context.Context, filter interface{}, opts ...*mopt.CountOptions) (int64, error) + CountDocuments(ctx context.Context, filter any, opts ...*mopt.CountOptions) (int64, error) // Database returns the database that this collection is a part of. Database() *mongo.Database // DeleteMany deletes documents from the collection that match the filter. - DeleteMany(ctx context.Context, filter interface{}, opts ...*mopt.DeleteOptions) ( + DeleteMany(ctx context.Context, filter any, opts ...*mopt.DeleteOptions) ( *mongo.DeleteResult, error) // DeleteOne deletes at most one document from the collection that matches the filter. - DeleteOne(ctx context.Context, filter interface{}, opts ...*mopt.DeleteOptions) ( + DeleteOne(ctx context.Context, filter any, opts ...*mopt.DeleteOptions) ( *mongo.DeleteResult, error) // Distinct returns a list of distinct values for the given key across the collection. - Distinct(ctx context.Context, fieldName string, filter interface{}, - opts ...*mopt.DistinctOptions) ([]interface{}, error) + Distinct(ctx context.Context, fieldName string, filter any, + opts ...*mopt.DistinctOptions) ([]any, error) // Drop drops this collection from database. Drop(ctx context.Context) error // EstimatedDocumentCount returns an estimate of the count of documents in a collection // using collection metadata. EstimatedDocumentCount(ctx context.Context, opts ...*mopt.EstimatedDocumentCountOptions) (int64, error) // Find finds the documents matching the provided filter. - Find(ctx context.Context, filter interface{}, opts ...*mopt.FindOptions) (*mongo.Cursor, error) + Find(ctx context.Context, filter any, opts ...*mopt.FindOptions) (*mongo.Cursor, error) // FindOne returns up to one document that matches the provided filter. - FindOne(ctx context.Context, filter interface{}, opts ...*mopt.FindOneOptions) ( + FindOne(ctx context.Context, filter any, opts ...*mopt.FindOneOptions) ( *mongo.SingleResult, error) // FindOneAndDelete returns at most one document that matches the filter. If the filter // matches multiple documents, only the first document is deleted. - FindOneAndDelete(ctx context.Context, filter interface{}, opts ...*mopt.FindOneAndDeleteOptions) ( + FindOneAndDelete(ctx context.Context, filter any, opts ...*mopt.FindOneAndDeleteOptions) ( *mongo.SingleResult, error) // FindOneAndReplace returns at most one document that matches the filter. If the filter // matches multiple documents, FindOneAndReplace returns the first document in the // collection that matches the filter. - FindOneAndReplace(ctx context.Context, filter, replacement interface{}, + FindOneAndReplace(ctx context.Context, filter, replacement any, opts ...*mopt.FindOneAndReplaceOptions) (*mongo.SingleResult, error) // FindOneAndUpdate returns at most one document that matches the filter. If the filter // matches multiple documents, FindOneAndUpdate returns the first document in the // collection that matches the filter. - FindOneAndUpdate(ctx context.Context, filter, update interface{}, + FindOneAndUpdate(ctx context.Context, filter, update any, opts ...*mopt.FindOneAndUpdateOptions) (*mongo.SingleResult, error) // Indexes returns the index view for this collection. Indexes() mongo.IndexView // InsertMany inserts the provided documents. - InsertMany(ctx context.Context, documents []interface{}, opts ...*mopt.InsertManyOptions) ( + InsertMany(ctx context.Context, documents []any, opts ...*mopt.InsertManyOptions) ( *mongo.InsertManyResult, error) // InsertOne inserts the provided document. - InsertOne(ctx context.Context, document interface{}, opts ...*mopt.InsertOneOptions) ( + InsertOne(ctx context.Context, document any, opts ...*mopt.InsertOneOptions) ( *mongo.InsertOneResult, error) // ReplaceOne replaces at most one document that matches the filter. - ReplaceOne(ctx context.Context, filter, replacement interface{}, + ReplaceOne(ctx context.Context, filter, replacement any, opts ...*mopt.ReplaceOptions) (*mongo.UpdateResult, error) // UpdateByID updates a single document matching the provided filter. - UpdateByID(ctx context.Context, id, update interface{}, + UpdateByID(ctx context.Context, id, update any, opts ...*mopt.UpdateOptions) (*mongo.UpdateResult, error) // UpdateMany updates the provided documents. - UpdateMany(ctx context.Context, filter, update interface{}, + UpdateMany(ctx context.Context, filter, update any, opts ...*mopt.UpdateOptions) (*mongo.UpdateResult, error) // UpdateOne updates a single document matching the provided filter. - UpdateOne(ctx context.Context, filter, update interface{}, + UpdateOne(ctx context.Context, filter, update any, opts ...*mopt.UpdateOptions) (*mongo.UpdateResult, error) // Watch returns a change stream cursor used to receive notifications of changes to the collection. - Watch(ctx context.Context, pipeline interface{}, opts ...*mopt.ChangeStreamOptions) ( + Watch(ctx context.Context, pipeline any, opts ...*mopt.ChangeStreamOptions) ( *mongo.ChangeStream, error) } @@ -135,7 +135,7 @@ func newCollection(collection *mongo.Collection, brk breaker.Breaker) Collection } } -func (c *decoratedCollection) Aggregate(ctx context.Context, pipeline interface{}, +func (c *decoratedCollection) Aggregate(ctx context.Context, pipeline any, opts ...*mopt.AggregateOptions) (cur *mongo.Cursor, err error) { ctx, span := startSpan(ctx, aggregate) defer func() { @@ -175,7 +175,7 @@ func (c *decoratedCollection) BulkWrite(ctx context.Context, models []mongo.Writ return } -func (c *decoratedCollection) CountDocuments(ctx context.Context, filter interface{}, +func (c *decoratedCollection) CountDocuments(ctx context.Context, filter any, opts ...*mopt.CountOptions) (count int64, err error) { ctx, span := startSpan(ctx, countDocuments) defer func() { @@ -195,7 +195,7 @@ func (c *decoratedCollection) CountDocuments(ctx context.Context, filter interfa return } -func (c *decoratedCollection) DeleteMany(ctx context.Context, filter interface{}, +func (c *decoratedCollection) DeleteMany(ctx context.Context, filter any, opts ...*mopt.DeleteOptions) (res *mongo.DeleteResult, err error) { ctx, span := startSpan(ctx, deleteMany) defer func() { @@ -215,7 +215,7 @@ func (c *decoratedCollection) DeleteMany(ctx context.Context, filter interface{} return } -func (c *decoratedCollection) DeleteOne(ctx context.Context, filter interface{}, +func (c *decoratedCollection) DeleteOne(ctx context.Context, filter any, opts ...*mopt.DeleteOptions) (res *mongo.DeleteResult, err error) { ctx, span := startSpan(ctx, deleteOne) defer func() { @@ -235,8 +235,8 @@ func (c *decoratedCollection) DeleteOne(ctx context.Context, filter interface{}, return } -func (c *decoratedCollection) Distinct(ctx context.Context, fieldName string, filter interface{}, - opts ...*mopt.DistinctOptions) (val []interface{}, err error) { +func (c *decoratedCollection) Distinct(ctx context.Context, fieldName string, filter any, + opts ...*mopt.DistinctOptions) (val []any, err error) { ctx, span := startSpan(ctx, distinct) defer func() { endSpan(span, err) @@ -275,7 +275,7 @@ func (c *decoratedCollection) EstimatedDocumentCount(ctx context.Context, return } -func (c *decoratedCollection) Find(ctx context.Context, filter interface{}, +func (c *decoratedCollection) Find(ctx context.Context, filter any, opts ...*mopt.FindOptions) (cur *mongo.Cursor, err error) { ctx, span := startSpan(ctx, find) defer func() { @@ -295,7 +295,7 @@ func (c *decoratedCollection) Find(ctx context.Context, filter interface{}, return } -func (c *decoratedCollection) FindOne(ctx context.Context, filter interface{}, +func (c *decoratedCollection) FindOne(ctx context.Context, filter any, opts ...*mopt.FindOneOptions) (res *mongo.SingleResult, err error) { ctx, span := startSpan(ctx, findOne) defer func() { @@ -316,7 +316,7 @@ func (c *decoratedCollection) FindOne(ctx context.Context, filter interface{}, return } -func (c *decoratedCollection) FindOneAndDelete(ctx context.Context, filter interface{}, +func (c *decoratedCollection) FindOneAndDelete(ctx context.Context, filter any, opts ...*mopt.FindOneAndDeleteOptions) (res *mongo.SingleResult, err error) { ctx, span := startSpan(ctx, findOneAndDelete) defer func() { @@ -337,8 +337,8 @@ func (c *decoratedCollection) FindOneAndDelete(ctx context.Context, filter inter return } -func (c *decoratedCollection) FindOneAndReplace(ctx context.Context, filter interface{}, - replacement interface{}, opts ...*mopt.FindOneAndReplaceOptions) ( +func (c *decoratedCollection) FindOneAndReplace(ctx context.Context, filter any, + replacement any, opts ...*mopt.FindOneAndReplaceOptions) ( res *mongo.SingleResult, err error) { ctx, span := startSpan(ctx, findOneAndReplace) defer func() { @@ -359,7 +359,7 @@ func (c *decoratedCollection) FindOneAndReplace(ctx context.Context, filter inte return } -func (c *decoratedCollection) FindOneAndUpdate(ctx context.Context, filter, update interface{}, +func (c *decoratedCollection) FindOneAndUpdate(ctx context.Context, filter, update any, opts ...*mopt.FindOneAndUpdateOptions) (res *mongo.SingleResult, err error) { ctx, span := startSpan(ctx, findOneAndUpdate) defer func() { @@ -380,7 +380,7 @@ func (c *decoratedCollection) FindOneAndUpdate(ctx context.Context, filter, upda return } -func (c *decoratedCollection) InsertMany(ctx context.Context, documents []interface{}, +func (c *decoratedCollection) InsertMany(ctx context.Context, documents []any, opts ...*mopt.InsertManyOptions) (res *mongo.InsertManyResult, err error) { ctx, span := startSpan(ctx, insertMany) defer func() { @@ -400,7 +400,7 @@ func (c *decoratedCollection) InsertMany(ctx context.Context, documents []interf return } -func (c *decoratedCollection) InsertOne(ctx context.Context, document interface{}, +func (c *decoratedCollection) InsertOne(ctx context.Context, document any, opts ...*mopt.InsertOneOptions) (res *mongo.InsertOneResult, err error) { ctx, span := startSpan(ctx, insertOne) defer func() { @@ -420,7 +420,7 @@ func (c *decoratedCollection) InsertOne(ctx context.Context, document interface{ return } -func (c *decoratedCollection) ReplaceOne(ctx context.Context, filter, replacement interface{}, +func (c *decoratedCollection) ReplaceOne(ctx context.Context, filter, replacement any, opts ...*mopt.ReplaceOptions) (res *mongo.UpdateResult, err error) { ctx, span := startSpan(ctx, replaceOne) defer func() { @@ -440,7 +440,7 @@ func (c *decoratedCollection) ReplaceOne(ctx context.Context, filter, replacemen return } -func (c *decoratedCollection) UpdateByID(ctx context.Context, id, update interface{}, +func (c *decoratedCollection) UpdateByID(ctx context.Context, id, update any, opts ...*mopt.UpdateOptions) (res *mongo.UpdateResult, err error) { ctx, span := startSpan(ctx, updateByID) defer func() { @@ -460,7 +460,7 @@ func (c *decoratedCollection) UpdateByID(ctx context.Context, id, update interfa return } -func (c *decoratedCollection) UpdateMany(ctx context.Context, filter, update interface{}, +func (c *decoratedCollection) UpdateMany(ctx context.Context, filter, update any, opts ...*mopt.UpdateOptions) (res *mongo.UpdateResult, err error) { ctx, span := startSpan(ctx, updateMany) defer func() { @@ -480,7 +480,7 @@ func (c *decoratedCollection) UpdateMany(ctx context.Context, filter, update int return } -func (c *decoratedCollection) UpdateOne(ctx context.Context, filter, update interface{}, +func (c *decoratedCollection) UpdateOne(ctx context.Context, filter, update any, opts ...*mopt.UpdateOptions) (res *mongo.UpdateResult, err error) { ctx, span := startSpan(ctx, updateOne) defer func() { @@ -501,7 +501,7 @@ func (c *decoratedCollection) UpdateOne(ctx context.Context, filter, update inte } func (c *decoratedCollection) logDuration(ctx context.Context, method string, - startTime time.Duration, err error, docs ...interface{}) { + startTime time.Duration, err error, docs ...any) { duration := timex.Since(startTime) logger := logx.WithContext(ctx).WithDuration(duration) diff --git a/core/stores/mon/collection_test.go b/core/stores/mon/collection_test.go index 2a09e3ea..d3c14a49 100644 --- a/core/stores/mon/collection_test.go +++ b/core/stores/mon/collection_test.go @@ -422,7 +422,7 @@ func TestCollection_InsertMany(t *testing.T) { brk: breaker.NewBreaker(), } mt.AddMockResponses(mtest.CreateSuccessResponse(bson.D{{Key: "ok", Value: 1}}...)) - res, err := c.InsertMany(context.Background(), []interface{}{ + res, err := c.InsertMany(context.Background(), []any{ bson.D{{Key: "foo", Value: "bar"}}, bson.D{{Key: "foo", Value: "baz"}}, }) @@ -431,7 +431,7 @@ func TestCollection_InsertMany(t *testing.T) { assert.Equal(t, 2, len(res.InsertedIDs)) c.brk = new(dropBreaker) - _, err = c.InsertMany(context.Background(), []interface{}{bson.D{{Key: "foo", Value: "bar"}}}) + _, err = c.InsertMany(context.Background(), []any{bson.D{{Key: "foo", Value: "bar"}}}) assert.Equal(t, errDummy, err) }) } diff --git a/core/stores/mon/model.go b/core/stores/mon/model.go index d7ec04f2..712bbc9c 100644 --- a/core/stores/mon/model.go +++ b/core/stores/mon/model.go @@ -96,7 +96,7 @@ func (m *Model) StartSession(opts ...*mopt.SessionOptions) (sess mongo.Session, } // Aggregate executes an aggregation pipeline. -func (m *Model) Aggregate(ctx context.Context, v, pipeline interface{}, opts ...*mopt.AggregateOptions) error { +func (m *Model) Aggregate(ctx context.Context, v, pipeline any, opts ...*mopt.AggregateOptions) error { cur, err := m.Collection.Aggregate(ctx, pipeline, opts...) if err != nil { return err @@ -107,7 +107,7 @@ func (m *Model) Aggregate(ctx context.Context, v, pipeline interface{}, opts ... } // DeleteMany deletes documents that match the filter. -func (m *Model) DeleteMany(ctx context.Context, filter interface{}, opts ...*mopt.DeleteOptions) (int64, error) { +func (m *Model) DeleteMany(ctx context.Context, filter any, opts ...*mopt.DeleteOptions) (int64, error) { res, err := m.Collection.DeleteMany(ctx, filter, opts...) if err != nil { return 0, err @@ -117,7 +117,7 @@ func (m *Model) DeleteMany(ctx context.Context, filter interface{}, opts ...*mop } // DeleteOne deletes the first document that matches the filter. -func (m *Model) DeleteOne(ctx context.Context, filter interface{}, opts ...*mopt.DeleteOptions) (int64, error) { +func (m *Model) DeleteOne(ctx context.Context, filter any, opts ...*mopt.DeleteOptions) (int64, error) { res, err := m.Collection.DeleteOne(ctx, filter, opts...) if err != nil { return 0, err @@ -127,7 +127,7 @@ func (m *Model) DeleteOne(ctx context.Context, filter interface{}, opts ...*mopt } // Find finds documents that match the filter. -func (m *Model) Find(ctx context.Context, v, filter interface{}, opts ...*mopt.FindOptions) error { +func (m *Model) Find(ctx context.Context, v, filter any, opts ...*mopt.FindOptions) error { cur, err := m.Collection.Find(ctx, filter, opts...) if err != nil { return err @@ -138,7 +138,7 @@ func (m *Model) Find(ctx context.Context, v, filter interface{}, opts ...*mopt.F } // FindOne finds the first document that matches the filter. -func (m *Model) FindOne(ctx context.Context, v, filter interface{}, opts ...*mopt.FindOneOptions) error { +func (m *Model) FindOne(ctx context.Context, v, filter any, opts ...*mopt.FindOneOptions) error { res, err := m.Collection.FindOne(ctx, filter, opts...) if err != nil { return err @@ -148,7 +148,7 @@ func (m *Model) FindOne(ctx context.Context, v, filter interface{}, opts ...*mop } // FindOneAndDelete finds a single document and deletes it. -func (m *Model) FindOneAndDelete(ctx context.Context, v, filter interface{}, +func (m *Model) FindOneAndDelete(ctx context.Context, v, filter any, opts ...*mopt.FindOneAndDeleteOptions) error { res, err := m.Collection.FindOneAndDelete(ctx, filter, opts...) if err != nil { @@ -159,7 +159,7 @@ func (m *Model) FindOneAndDelete(ctx context.Context, v, filter interface{}, } // FindOneAndReplace finds a single document and replaces it. -func (m *Model) FindOneAndReplace(ctx context.Context, v, filter, replacement interface{}, +func (m *Model) FindOneAndReplace(ctx context.Context, v, filter, replacement any, opts ...*mopt.FindOneAndReplaceOptions) error { res, err := m.Collection.FindOneAndReplace(ctx, filter, replacement, opts...) if err != nil { @@ -170,7 +170,7 @@ func (m *Model) FindOneAndReplace(ctx context.Context, v, filter, replacement in } // FindOneAndUpdate finds a single document and updates it. -func (m *Model) FindOneAndUpdate(ctx context.Context, v, filter, update interface{}, +func (m *Model) FindOneAndUpdate(ctx context.Context, v, filter, update any, opts ...*mopt.FindOneAndUpdateOptions) error { res, err := m.Collection.FindOneAndUpdate(ctx, filter, update, opts...) if err != nil { @@ -217,9 +217,9 @@ func (w *wrappedSession) CommitTransaction(ctx context.Context) (err error) { // WithTransaction implements the mongo.Session interface. func (w *wrappedSession) WithTransaction( ctx context.Context, - fn func(sessCtx mongo.SessionContext) (interface{}, error), + fn func(sessCtx mongo.SessionContext) (any, error), opts ...*mopt.TransactionOptions, -) (res interface{}, err error) { +) (res any, err error) { ctx, span := startSpan(ctx, withTransaction) defer func() { endSpan(span, err) diff --git a/core/stores/mon/model_test.go b/core/stores/mon/model_test.go index d86b15ef..4db60d83 100644 --- a/core/stores/mon/model_test.go +++ b/core/stores/mon/model_test.go @@ -20,7 +20,7 @@ func TestModel_StartSession(t *testing.T) { assert.Nil(t, err) defer sess.EndSession(context.Background()) - _, err = sess.WithTransaction(context.Background(), func(sessCtx mongo.SessionContext) (interface{}, error) { + _, err = sess.WithTransaction(context.Background(), func(sessCtx mongo.SessionContext) (any, error) { _ = sessCtx.StartTransaction() sessCtx.Client().Database("1") sessCtx.EndSession(context.Background()) @@ -57,7 +57,7 @@ func TestModel_Aggregate(t *testing.T) { "DBName.CollectionName", mtest.NextBatch) mt.AddMockResponses(find, getMore, killCursors) - var result []interface{} + var result []any err := m.Aggregate(context.Background(), &result, mongo.Pipeline{}) assert.Nil(t, err) assert.Equal(t, 2, len(result)) @@ -128,7 +128,7 @@ func TestModel_Find(t *testing.T) { "DBName.CollectionName", mtest.NextBatch) mt.AddMockResponses(find, getMore, killCursors) - var result []interface{} + var result []any err := m.Find(context.Background(), &result, bson.D{}) assert.Nil(t, err) assert.Equal(t, 2, len(result)) diff --git a/core/stores/monc/cachedmodel.go b/core/stores/monc/cachedmodel.go index 7c1eeb84..54deec3b 100644 --- a/core/stores/monc/cachedmodel.go +++ b/core/stores/monc/cachedmodel.go @@ -83,7 +83,7 @@ func (mm *Model) DelCache(ctx context.Context, keys ...string) error { } // DeleteOne deletes the document with given filter, and remove it from cache. -func (mm *Model) DeleteOne(ctx context.Context, key string, filter interface{}, +func (mm *Model) DeleteOne(ctx context.Context, key string, filter any, opts ...*mopt.DeleteOptions) (int64, error) { val, err := mm.Model.DeleteOne(ctx, filter, opts...) if err != nil { @@ -98,27 +98,27 @@ func (mm *Model) DeleteOne(ctx context.Context, key string, filter interface{}, } // DeleteOneNoCache deletes the document with given filter. -func (mm *Model) DeleteOneNoCache(ctx context.Context, filter interface{}, +func (mm *Model) DeleteOneNoCache(ctx context.Context, filter any, opts ...*mopt.DeleteOptions) (int64, error) { return mm.Model.DeleteOne(ctx, filter, opts...) } // FindOne unmarshals a record into v with given key and query. -func (mm *Model) FindOne(ctx context.Context, key string, v, filter interface{}, +func (mm *Model) FindOne(ctx context.Context, key string, v, filter any, opts ...*mopt.FindOneOptions) error { - return mm.cache.TakeCtx(ctx, v, key, func(v interface{}) error { + return mm.cache.TakeCtx(ctx, v, key, func(v any) error { return mm.Model.FindOne(ctx, v, filter, opts...) }) } // FindOneNoCache unmarshals a record into v with query, without cache. -func (mm *Model) FindOneNoCache(ctx context.Context, v, filter interface{}, +func (mm *Model) FindOneNoCache(ctx context.Context, v, filter any, opts ...*mopt.FindOneOptions) error { return mm.Model.FindOne(ctx, v, filter, opts...) } // FindOneAndDelete deletes the document with given filter, and unmarshals it into v. -func (mm *Model) FindOneAndDelete(ctx context.Context, key string, v, filter interface{}, +func (mm *Model) FindOneAndDelete(ctx context.Context, key string, v, filter any, opts ...*mopt.FindOneAndDeleteOptions) error { if err := mm.Model.FindOneAndDelete(ctx, v, filter, opts...); err != nil { return err @@ -128,14 +128,14 @@ func (mm *Model) FindOneAndDelete(ctx context.Context, key string, v, filter int } // FindOneAndDeleteNoCache deletes the document with given filter, and unmarshals it into v. -func (mm *Model) FindOneAndDeleteNoCache(ctx context.Context, v, filter interface{}, +func (mm *Model) FindOneAndDeleteNoCache(ctx context.Context, v, filter any, opts ...*mopt.FindOneAndDeleteOptions) error { return mm.Model.FindOneAndDelete(ctx, v, filter, opts...) } // FindOneAndReplace replaces the document with given filter with replacement, and unmarshals it into v. -func (mm *Model) FindOneAndReplace(ctx context.Context, key string, v, filter interface{}, - replacement interface{}, opts ...*mopt.FindOneAndReplaceOptions) error { +func (mm *Model) FindOneAndReplace(ctx context.Context, key string, v, filter any, + replacement any, opts ...*mopt.FindOneAndReplaceOptions) error { if err := mm.Model.FindOneAndReplace(ctx, v, filter, replacement, opts...); err != nil { return err } @@ -144,14 +144,14 @@ func (mm *Model) FindOneAndReplace(ctx context.Context, key string, v, filter in } // FindOneAndReplaceNoCache replaces the document with given filter with replacement, and unmarshals it into v. -func (mm *Model) FindOneAndReplaceNoCache(ctx context.Context, v, filter interface{}, - replacement interface{}, opts ...*mopt.FindOneAndReplaceOptions) error { +func (mm *Model) FindOneAndReplaceNoCache(ctx context.Context, v, filter any, + replacement any, opts ...*mopt.FindOneAndReplaceOptions) error { return mm.Model.FindOneAndReplace(ctx, v, filter, replacement, opts...) } // FindOneAndUpdate updates the document with given filter with update, and unmarshals it into v. -func (mm *Model) FindOneAndUpdate(ctx context.Context, key string, v, filter interface{}, - update interface{}, opts ...*mopt.FindOneAndUpdateOptions) error { +func (mm *Model) FindOneAndUpdate(ctx context.Context, key string, v, filter any, + update any, opts ...*mopt.FindOneAndUpdateOptions) error { if err := mm.Model.FindOneAndUpdate(ctx, v, filter, update, opts...); err != nil { return err } @@ -160,18 +160,18 @@ func (mm *Model) FindOneAndUpdate(ctx context.Context, key string, v, filter int } // FindOneAndUpdateNoCache updates the document with given filter with update, and unmarshals it into v. -func (mm *Model) FindOneAndUpdateNoCache(ctx context.Context, v, filter interface{}, - update interface{}, opts ...*mopt.FindOneAndUpdateOptions) error { +func (mm *Model) FindOneAndUpdateNoCache(ctx context.Context, v, filter any, + update any, opts ...*mopt.FindOneAndUpdateOptions) error { return mm.Model.FindOneAndUpdate(ctx, v, filter, update, opts...) } // GetCache unmarshal the cache into v with given key. -func (mm *Model) GetCache(key string, v interface{}) error { +func (mm *Model) GetCache(key string, v any) error { return mm.cache.Get(key, v) } // InsertOne inserts a single document into the collection, and remove the cache placeholder. -func (mm *Model) InsertOne(ctx context.Context, key string, document interface{}, +func (mm *Model) InsertOne(ctx context.Context, key string, document any, opts ...*mopt.InsertOneOptions) (*mongo.InsertOneResult, error) { res, err := mm.Model.InsertOne(ctx, document, opts...) if err != nil { @@ -186,13 +186,13 @@ func (mm *Model) InsertOne(ctx context.Context, key string, document interface{} } // InsertOneNoCache inserts a single document into the collection. -func (mm *Model) InsertOneNoCache(ctx context.Context, document interface{}, +func (mm *Model) InsertOneNoCache(ctx context.Context, document any, opts ...*mopt.InsertOneOptions) (*mongo.InsertOneResult, error) { return mm.Model.InsertOne(ctx, document, opts...) } // ReplaceOne replaces a single document in the collection, and remove the cache. -func (mm *Model) ReplaceOne(ctx context.Context, key string, filter, replacement interface{}, +func (mm *Model) ReplaceOne(ctx context.Context, key string, filter, replacement any, opts ...*mopt.ReplaceOptions) (*mongo.UpdateResult, error) { res, err := mm.Model.ReplaceOne(ctx, filter, replacement, opts...) if err != nil { @@ -207,18 +207,18 @@ func (mm *Model) ReplaceOne(ctx context.Context, key string, filter, replacement } // ReplaceOneNoCache replaces a single document in the collection. -func (mm *Model) ReplaceOneNoCache(ctx context.Context, filter, replacement interface{}, +func (mm *Model) ReplaceOneNoCache(ctx context.Context, filter, replacement any, opts ...*mopt.ReplaceOptions) (*mongo.UpdateResult, error) { return mm.Model.ReplaceOne(ctx, filter, replacement, opts...) } // SetCache sets the cache with given key and value. -func (mm *Model) SetCache(key string, v interface{}) error { +func (mm *Model) SetCache(key string, v any) error { return mm.cache.Set(key, v) } // UpdateByID updates the document with given id with update, and remove the cache. -func (mm *Model) UpdateByID(ctx context.Context, key string, id, update interface{}, +func (mm *Model) UpdateByID(ctx context.Context, key string, id, update any, opts ...*mopt.UpdateOptions) (*mongo.UpdateResult, error) { res, err := mm.Model.UpdateByID(ctx, id, update, opts...) if err != nil { @@ -233,13 +233,13 @@ func (mm *Model) UpdateByID(ctx context.Context, key string, id, update interfac } // UpdateByIDNoCache updates the document with given id with update. -func (mm *Model) UpdateByIDNoCache(ctx context.Context, id, update interface{}, +func (mm *Model) UpdateByIDNoCache(ctx context.Context, id, update any, opts ...*mopt.UpdateOptions) (*mongo.UpdateResult, error) { return mm.Model.UpdateByID(ctx, id, update, opts...) } // UpdateMany updates the documents that match filter with update, and remove the cache. -func (mm *Model) UpdateMany(ctx context.Context, keys []string, filter, update interface{}, +func (mm *Model) UpdateMany(ctx context.Context, keys []string, filter, update any, opts ...*mopt.UpdateOptions) (*mongo.UpdateResult, error) { res, err := mm.Model.UpdateMany(ctx, filter, update, opts...) if err != nil { @@ -254,13 +254,13 @@ func (mm *Model) UpdateMany(ctx context.Context, keys []string, filter, update i } // UpdateManyNoCache updates the documents that match filter with update. -func (mm *Model) UpdateManyNoCache(ctx context.Context, filter, update interface{}, +func (mm *Model) UpdateManyNoCache(ctx context.Context, filter, update any, opts ...*mopt.UpdateOptions) (*mongo.UpdateResult, error) { return mm.Model.UpdateMany(ctx, filter, update, opts...) } // UpdateOne updates the first document that matches filter with update, and remove the cache. -func (mm *Model) UpdateOne(ctx context.Context, key string, filter, update interface{}, +func (mm *Model) UpdateOne(ctx context.Context, key string, filter, update any, opts ...*mopt.UpdateOptions) (*mongo.UpdateResult, error) { res, err := mm.Model.UpdateOne(ctx, filter, update, opts...) if err != nil { @@ -275,7 +275,7 @@ func (mm *Model) UpdateOne(ctx context.Context, key string, filter, update inter } // UpdateOneNoCache updates the first document that matches filter with update. -func (mm *Model) UpdateOneNoCache(ctx context.Context, filter, update interface{}, +func (mm *Model) UpdateOneNoCache(ctx context.Context, filter, update any, opts ...*mopt.UpdateOptions) (*mongo.UpdateResult, error) { return mm.Model.UpdateOne(ctx, filter, update, opts...) } diff --git a/core/stores/redis/redis.go b/core/stores/redis/redis.go index f6884efe..dcec2a7a 100644 --- a/core/stores/redis/redis.go +++ b/core/stores/redis/redis.go @@ -352,13 +352,13 @@ func (s *Redis) DelCtx(ctx context.Context, keys ...string) (val int, err error) } // Eval is the implementation of redis eval command. -func (s *Redis) Eval(script string, keys []string, args ...interface{}) (interface{}, error) { +func (s *Redis) Eval(script string, keys []string, args ...any) (any, error) { return s.EvalCtx(context.Background(), script, keys, args...) } // EvalCtx is the implementation of redis eval command. func (s *Redis) EvalCtx(ctx context.Context, script string, keys []string, - args ...interface{}) (val interface{}, err error) { + args ...any) (val any, err error) { err = s.brk.DoWithAcceptable(func() error { conn, err := getRedis(s) if err != nil { @@ -373,13 +373,13 @@ func (s *Redis) EvalCtx(ctx context.Context, script string, keys []string, } // EvalSha is the implementation of redis evalsha command. -func (s *Redis) EvalSha(sha string, keys []string, args ...interface{}) (interface{}, error) { +func (s *Redis) EvalSha(sha string, keys []string, args ...any) (any, error) { return s.EvalShaCtx(context.Background(), sha, keys, args...) } // EvalShaCtx is the implementation of redis evalsha command. func (s *Redis) EvalShaCtx(ctx context.Context, sha string, keys []string, - args ...interface{}) (val interface{}, err error) { + args ...any) (val any, err error) { err = s.brk.DoWithAcceptable(func() error { conn, err := getRedis(s) if err != nil { @@ -934,7 +934,7 @@ func (s *Redis) HmsetCtx(ctx context.Context, key string, fieldsAndValues map[st return err } - vals := make(map[string]interface{}, len(fieldsAndValues)) + vals := make(map[string]any, len(fieldsAndValues)) for k, v := range fieldsAndValues { vals[k] = v } @@ -1131,12 +1131,12 @@ func (s *Redis) LpopCtx(ctx context.Context, key string) (val string, err error) } // Lpush is the implementation of redis lpush command. -func (s *Redis) Lpush(key string, values ...interface{}) (int, error) { +func (s *Redis) Lpush(key string, values ...any) (int, error) { return s.LpushCtx(context.Background(), key, values...) } // LpushCtx is the implementation of redis lpush command. -func (s *Redis) LpushCtx(ctx context.Context, key string, values ...interface{}) (val int, err error) { +func (s *Redis) LpushCtx(ctx context.Context, key string, values ...any) (val int, err error) { err = s.brk.DoWithAcceptable(func() error { conn, err := getRedis(s) if err != nil { @@ -1263,12 +1263,12 @@ func (s *Redis) PersistCtx(ctx context.Context, key string) (val bool, err error } // Pfadd is the implementation of redis pfadd command. -func (s *Redis) Pfadd(key string, values ...interface{}) (bool, error) { +func (s *Redis) Pfadd(key string, values ...any) (bool, error) { return s.PfaddCtx(context.Background(), key, values...) } // PfaddCtx is the implementation of redis pfadd command. -func (s *Redis) PfaddCtx(ctx context.Context, key string, values ...interface{}) (val bool, err error) { +func (s *Redis) PfaddCtx(ctx context.Context, key string, values ...any) (val bool, err error) { err = s.brk.DoWithAcceptable(func() error { conn, err := getRedis(s) if err != nil { @@ -1393,12 +1393,12 @@ func (s *Redis) RpopCtx(ctx context.Context, key string) (val string, err error) } // Rpush is the implementation of redis rpush command. -func (s *Redis) Rpush(key string, values ...interface{}) (int, error) { +func (s *Redis) Rpush(key string, values ...any) (int, error) { return s.RpushCtx(context.Background(), key, values...) } // RpushCtx is the implementation of redis rpush command. -func (s *Redis) RpushCtx(ctx context.Context, key string, values ...interface{}) (val int, err error) { +func (s *Redis) RpushCtx(ctx context.Context, key string, values ...any) (val int, err error) { err = s.brk.DoWithAcceptable(func() error { conn, err := getRedis(s) if err != nil { @@ -1418,12 +1418,12 @@ func (s *Redis) RpushCtx(ctx context.Context, key string, values ...interface{}) } // Sadd is the implementation of redis sadd command. -func (s *Redis) Sadd(key string, values ...interface{}) (int, error) { +func (s *Redis) Sadd(key string, values ...any) (int, error) { return s.SaddCtx(context.Background(), key, values...) } // SaddCtx is the implementation of redis sadd command. -func (s *Redis) SaddCtx(ctx context.Context, key string, values ...interface{}) (val int, err error) { +func (s *Redis) SaddCtx(ctx context.Context, key string, values ...any) (val int, err error) { err = s.brk.DoWithAcceptable(func() error { conn, err := getRedis(s) if err != nil { @@ -1620,12 +1620,12 @@ func (s *Redis) SetnxExCtx(ctx context.Context, key, value string, seconds int) } // Sismember is the implementation of redis sismember command. -func (s *Redis) Sismember(key string, value interface{}) (bool, error) { +func (s *Redis) Sismember(key string, value any) (bool, error) { return s.SismemberCtx(context.Background(), key, value) } // SismemberCtx is the implementation of redis sismember command. -func (s *Redis) SismemberCtx(ctx context.Context, key string, value interface{}) (val bool, err error) { +func (s *Redis) SismemberCtx(ctx context.Context, key string, value any) (val bool, err error) { err = s.brk.DoWithAcceptable(func() error { conn, err := getRedis(s) if err != nil { @@ -1700,12 +1700,12 @@ func (s *Redis) SrandmemberCtx(ctx context.Context, key string, count int) (val } // Srem is the implementation of redis srem command. -func (s *Redis) Srem(key string, values ...interface{}) (int, error) { +func (s *Redis) Srem(key string, values ...any) (int, error) { return s.SremCtx(context.Background(), key, values...) } // SremCtx is the implementation of redis srem command. -func (s *Redis) SremCtx(ctx context.Context, key string, values ...interface{}) (val int, err error) { +func (s *Redis) SremCtx(ctx context.Context, key string, values ...any) (val int, err error) { err = s.brk.DoWithAcceptable(func() error { conn, err := getRedis(s) if err != nil { @@ -2127,12 +2127,12 @@ func (s *Redis) ZrankCtx(ctx context.Context, key, field string) (val int64, err } // Zrem is the implementation of redis zrem command. -func (s *Redis) Zrem(key string, values ...interface{}) (int, error) { +func (s *Redis) Zrem(key string, values ...any) (int, error) { return s.ZremCtx(context.Background(), key, values...) } // ZremCtx is the implementation of redis zrem command. -func (s *Redis) ZremCtx(ctx context.Context, key string, values ...interface{}) (val int, err error) { +func (s *Redis) ZremCtx(ctx context.Context, key string, values ...any) (val int, err error) { err = s.brk.DoWithAcceptable(func() error { conn, err := getRedis(s) if err != nil { @@ -2770,7 +2770,7 @@ func toFloatPairs(vals []red.Z) []FloatPair { return pairs } -func toStrings(vals []interface{}) []string { +func toStrings(vals []any) []string { ret := make([]string, len(vals)) for i, val := range vals { diff --git a/core/stores/redis/redis_test.go b/core/stores/redis/redis_test.go index 2c7e52e2..2273f713 100644 --- a/core/stores/redis/redis_test.go +++ b/core/stores/redis/redis_test.go @@ -1518,7 +1518,7 @@ func TestRedis_Zscan(t *testing.T) { } func TestRedisToStrings(t *testing.T) { - vals := toStrings([]interface{}{1, 2}) + vals := toStrings([]any{1, 2}) assert.EqualValues(t, []string{"1", "2"}, vals) } diff --git a/core/stores/sqlc/cachedsql.go b/core/stores/sqlc/cachedsql.go index 10012c4e..52e5ee04 100644 --- a/core/stores/sqlc/cachedsql.go +++ b/core/stores/sqlc/cachedsql.go @@ -29,17 +29,17 @@ type ( // ExecCtxFn defines the sql exec method. ExecCtxFn func(ctx context.Context, conn sqlx.SqlConn) (sql.Result, error) // IndexQueryFn defines the query method that based on unique indexes. - IndexQueryFn func(conn sqlx.SqlConn, v interface{}) (interface{}, error) + IndexQueryFn func(conn sqlx.SqlConn, v any) (any, error) // IndexQueryCtxFn defines the query method that based on unique indexes. - IndexQueryCtxFn func(ctx context.Context, conn sqlx.SqlConn, v interface{}) (interface{}, error) + IndexQueryCtxFn func(ctx context.Context, conn sqlx.SqlConn, v any) (any, error) // PrimaryQueryFn defines the query method that based on primary keys. - PrimaryQueryFn func(conn sqlx.SqlConn, v, primary interface{}) error + PrimaryQueryFn func(conn sqlx.SqlConn, v, primary any) error // PrimaryQueryCtxFn defines the query method that based on primary keys. - PrimaryQueryCtxFn func(ctx context.Context, conn sqlx.SqlConn, v, primary interface{}) error + PrimaryQueryCtxFn func(ctx context.Context, conn sqlx.SqlConn, v, primary any) error // QueryFn defines the query method. - QueryFn func(conn sqlx.SqlConn, v interface{}) error + QueryFn func(conn sqlx.SqlConn, v any) error // QueryCtxFn defines the query method. - QueryCtxFn func(ctx context.Context, conn sqlx.SqlConn, v interface{}) error + QueryCtxFn func(ctx context.Context, conn sqlx.SqlConn, v any) error // A CachedConn is a DB connection with cache capability. CachedConn struct { @@ -79,12 +79,12 @@ func (cc CachedConn) DelCacheCtx(ctx context.Context, keys ...string) error { } // GetCache unmarshals cache with given key into v. -func (cc CachedConn) GetCache(key string, v interface{}) error { +func (cc CachedConn) GetCache(key string, v any) error { return cc.GetCacheCtx(context.Background(), key, v) } // GetCacheCtx unmarshals cache with given key into v. -func (cc CachedConn) GetCacheCtx(ctx context.Context, key string, v interface{}) error { +func (cc CachedConn) GetCacheCtx(ctx context.Context, key string, v any) error { return cc.cache.GetCtx(ctx, key, v) } @@ -112,38 +112,38 @@ func (cc CachedConn) ExecCtx(ctx context.Context, exec ExecCtxFn, keys ...string } // ExecNoCache runs exec with given sql statement, without affecting cache. -func (cc CachedConn) ExecNoCache(q string, args ...interface{}) (sql.Result, error) { +func (cc CachedConn) ExecNoCache(q string, args ...any) (sql.Result, error) { return cc.ExecNoCacheCtx(context.Background(), q, args...) } // ExecNoCacheCtx runs exec with given sql statement, without affecting cache. -func (cc CachedConn) ExecNoCacheCtx(ctx context.Context, q string, args ...interface{}) ( +func (cc CachedConn) ExecNoCacheCtx(ctx context.Context, q string, args ...any) ( sql.Result, error) { return cc.db.ExecCtx(ctx, q, args...) } // QueryRow unmarshals into v with given key and query func. -func (cc CachedConn) QueryRow(v interface{}, key string, query QueryFn) error { - queryCtx := func(_ context.Context, conn sqlx.SqlConn, v interface{}) error { +func (cc CachedConn) QueryRow(v any, key string, query QueryFn) error { + queryCtx := func(_ context.Context, conn sqlx.SqlConn, v any) error { return query(conn, v) } return cc.QueryRowCtx(context.Background(), v, key, queryCtx) } // QueryRowCtx unmarshals into v with given key and query func. -func (cc CachedConn) QueryRowCtx(ctx context.Context, v interface{}, key string, query QueryCtxFn) error { - return cc.cache.TakeCtx(ctx, v, key, func(v interface{}) error { +func (cc CachedConn) QueryRowCtx(ctx context.Context, v any, key string, query QueryCtxFn) error { + return cc.cache.TakeCtx(ctx, v, key, func(v any) error { return query(ctx, cc.db, v) }) } // QueryRowIndex unmarshals into v with given key. -func (cc CachedConn) QueryRowIndex(v interface{}, key string, keyer func(primary interface{}) string, +func (cc CachedConn) QueryRowIndex(v any, key string, keyer func(primary any) string, indexQuery IndexQueryFn, primaryQuery PrimaryQueryFn) error { - indexQueryCtx := func(_ context.Context, conn sqlx.SqlConn, v interface{}) (interface{}, error) { + indexQueryCtx := func(_ context.Context, conn sqlx.SqlConn, v any) (any, error) { return indexQuery(conn, v) } - primaryQueryCtx := func(_ context.Context, conn sqlx.SqlConn, v, primary interface{}) error { + primaryQueryCtx := func(_ context.Context, conn sqlx.SqlConn, v, primary any) error { return primaryQuery(conn, v, primary) } @@ -151,14 +151,14 @@ func (cc CachedConn) QueryRowIndex(v interface{}, key string, keyer func(primary } // QueryRowIndexCtx unmarshals into v with given key. -func (cc CachedConn) QueryRowIndexCtx(ctx context.Context, v interface{}, key string, - keyer func(primary interface{}) string, indexQuery IndexQueryCtxFn, +func (cc CachedConn) QueryRowIndexCtx(ctx context.Context, v any, key string, + keyer func(primary any) string, indexQuery IndexQueryCtxFn, primaryQuery PrimaryQueryCtxFn) error { - var primaryKey interface{} + var primaryKey any var found bool if err := cc.cache.TakeWithExpireCtx(ctx, &primaryKey, key, - func(val interface{}, expire time.Duration) (err error) { + func(val any, expire time.Duration) (err error) { primaryKey, err = indexQuery(ctx, cc.db, v) if err != nil { return @@ -175,42 +175,42 @@ func (cc CachedConn) QueryRowIndexCtx(ctx context.Context, v interface{}, key st return nil } - return cc.cache.TakeCtx(ctx, v, keyer(primaryKey), func(v interface{}) error { + return cc.cache.TakeCtx(ctx, v, keyer(primaryKey), func(v any) error { return primaryQuery(ctx, cc.db, v, primaryKey) }) } // QueryRowNoCache unmarshals into v with given statement. -func (cc CachedConn) QueryRowNoCache(v interface{}, q string, args ...interface{}) error { +func (cc CachedConn) QueryRowNoCache(v any, q string, args ...any) error { return cc.QueryRowNoCacheCtx(context.Background(), v, q, args...) } // QueryRowNoCacheCtx unmarshals into v with given statement. -func (cc CachedConn) QueryRowNoCacheCtx(ctx context.Context, v interface{}, q string, - args ...interface{}) error { +func (cc CachedConn) QueryRowNoCacheCtx(ctx context.Context, v any, q string, + args ...any) error { return cc.db.QueryRowCtx(ctx, v, q, args...) } // QueryRowsNoCache unmarshals into v with given statement. // It doesn't use cache, because it might cause consistency problem. -func (cc CachedConn) QueryRowsNoCache(v interface{}, q string, args ...interface{}) error { +func (cc CachedConn) QueryRowsNoCache(v any, q string, args ...any) error { return cc.QueryRowsNoCacheCtx(context.Background(), v, q, args...) } // QueryRowsNoCacheCtx unmarshals into v with given statement. // It doesn't use cache, because it might cause consistency problem. -func (cc CachedConn) QueryRowsNoCacheCtx(ctx context.Context, v interface{}, q string, - args ...interface{}) error { +func (cc CachedConn) QueryRowsNoCacheCtx(ctx context.Context, v any, q string, + args ...any) error { return cc.db.QueryRowsCtx(ctx, v, q, args...) } // SetCache sets v into cache with given key. -func (cc CachedConn) SetCache(key string, val interface{}) error { +func (cc CachedConn) SetCache(key string, val any) error { return cc.SetCacheCtx(context.Background(), key, val) } // SetCacheCtx sets v into cache with given key. -func (cc CachedConn) SetCacheCtx(ctx context.Context, key string, val interface{}) error { +func (cc CachedConn) SetCacheCtx(ctx context.Context, key string, val any) error { return cc.cache.SetCtx(ctx, key, val) } diff --git a/core/stores/sqlc/cachedsql_test.go b/core/stores/sqlc/cachedsql_test.go index 199cb6bc..72ffa6fd 100644 --- a/core/stores/sqlc/cachedsql_test.go +++ b/core/stores/sqlc/cachedsql_test.go @@ -57,7 +57,7 @@ func TestStat(t *testing.T) { for i := 0; i < 10; i++ { var str string - err = c.QueryRow(&str, "name", func(conn sqlx.SqlConn, v interface{}) error { + err = c.QueryRow(&str, "name", func(conn sqlx.SqlConn, v any) error { *v.(*string) = "zero" return nil }) @@ -87,24 +87,24 @@ func TestCachedConn_QueryRowIndex_NoCache(t *testing.T) { }, cache.WithExpiry(time.Second*10)) var str string - err = c.QueryRowIndex(&str, "index", func(s interface{}) string { + err = c.QueryRowIndex(&str, "index", func(s any) string { return fmt.Sprintf("%s/1234", s) - }, func(conn sqlx.SqlConn, v interface{}) (interface{}, error) { + }, func(conn sqlx.SqlConn, v any) (any, error) { *v.(*string) = "zero" return "primary", errors.New("foo") - }, func(conn sqlx.SqlConn, v, pri interface{}) error { + }, func(conn sqlx.SqlConn, v, pri any) error { assert.Equal(t, "primary", pri) *v.(*string) = "xin" return nil }) assert.NotNil(t, err) - err = c.QueryRowIndex(&str, "index", func(s interface{}) string { + err = c.QueryRowIndex(&str, "index", func(s any) string { return fmt.Sprintf("%s/1234", s) - }, func(conn sqlx.SqlConn, v interface{}) (interface{}, error) { + }, func(conn sqlx.SqlConn, v any) (any, error) { *v.(*string) = "zero" return "primary", nil - }, func(conn sqlx.SqlConn, v, pri interface{}) error { + }, func(conn sqlx.SqlConn, v, pri any) error { assert.Equal(t, "primary", pri) *v.(*string) = "xin" return nil @@ -130,12 +130,12 @@ func TestCachedConn_QueryRowIndex_HasCache(t *testing.T) { var str string r.Set("index", `"primary"`) - err = c.QueryRowIndex(&str, "index", func(s interface{}) string { + err = c.QueryRowIndex(&str, "index", func(s any) string { return fmt.Sprintf("%s/1234", s) - }, func(conn sqlx.SqlConn, v interface{}) (interface{}, error) { + }, func(conn sqlx.SqlConn, v any) (any, error) { assert.Fail(t, "should not go here") return "primary", nil - }, func(conn sqlx.SqlConn, v, primary interface{}) error { + }, func(conn sqlx.SqlConn, v, primary any) error { *v.(*string) = "xin" assert.Equal(t, "primary", primary) return nil @@ -163,7 +163,7 @@ func TestCachedConn_QueryRowIndex_HasCache_IntPrimary(t *testing.T) { ) tests := []struct { name string - primary interface{} + primary any primaryCache string }{ { @@ -220,12 +220,12 @@ func TestCachedConn_QueryRowIndex_HasCache_IntPrimary(t *testing.T) { var str string r.Set("index", test.primaryCache) - err = c.QueryRowIndex(&str, "index", func(s interface{}) string { + err = c.QueryRowIndex(&str, "index", func(s any) string { return fmt.Sprintf("%v/1234", s) - }, func(conn sqlx.SqlConn, v interface{}) (interface{}, error) { + }, func(conn sqlx.SqlConn, v any) (any, error) { assert.Fail(t, "should not go here") return test.primary, nil - }, func(conn sqlx.SqlConn, v, primary interface{}) error { + }, func(conn sqlx.SqlConn, v, primary any) error { *v.(*string) = "xin" assert.Equal(t, primary, primary) return nil @@ -260,12 +260,12 @@ func TestCachedConn_QueryRowIndex_HasWrongCache(t *testing.T) { var str string r.Set(k, v) - err = c.QueryRowIndex(&str, "index", func(s interface{}) string { + err = c.QueryRowIndex(&str, "index", func(s any) string { return fmt.Sprintf("%s/1234", s) - }, func(conn sqlx.SqlConn, v interface{}) (interface{}, error) { + }, func(conn sqlx.SqlConn, v any) (any, error) { *v.(*string) = "xin" return "primary", nil - }, func(conn sqlx.SqlConn, v, primary interface{}) error { + }, func(conn sqlx.SqlConn, v, primary any) error { *v.(*string) = "xin" assert.Equal(t, "primary", primary) return nil @@ -292,7 +292,7 @@ func TestStatCacheFails(t *testing.T) { for i := 0; i < 20; i++ { var str string - err := c.QueryRow(&str, "name", func(conn sqlx.SqlConn, v interface{}) error { + err := c.QueryRow(&str, "name", func(conn sqlx.SqlConn, v any) error { return errors.New("db failed") }) assert.NotNil(t, err) @@ -314,7 +314,7 @@ func TestStatDbFails(t *testing.T) { for i := 0; i < 20; i++ { var str string - err = c.QueryRow(&str, "name", func(conn sqlx.SqlConn, v interface{}) error { + err = c.QueryRow(&str, "name", func(conn sqlx.SqlConn, v any) error { return errors.New("db failed") }) assert.NotNil(t, err) @@ -339,7 +339,7 @@ func TestStatFromMemory(t *testing.T) { wait.Add(4) go func() { var str string - err := c.QueryRow(&str, "name", func(conn sqlx.SqlConn, v interface{}) error { + err := c.QueryRow(&str, "name", func(conn sqlx.SqlConn, v any) error { *v.(*string) = "zero" return nil }) @@ -355,7 +355,7 @@ func TestStatFromMemory(t *testing.T) { go func() { var str string wait.Done() - err := c.QueryRow(&str, "name", func(conn sqlx.SqlConn, v interface{}) error { + err := c.QueryRow(&str, "name", func(conn sqlx.SqlConn, v any) error { *v.(*string) = "zero" return nil }) @@ -368,7 +368,7 @@ func TestStatFromMemory(t *testing.T) { for i := 0; i < 5; i++ { go func() { var str string - err := c.QueryRow(&str, "name", func(conn sqlx.SqlConn, v interface{}) error { + err := c.QueryRow(&str, "name", func(conn sqlx.SqlConn, v any) error { *v.(*string) = "zero" return nil }) @@ -397,7 +397,7 @@ func TestCachedConnQueryRow(t *testing.T) { var user string var ran bool c := NewNodeConn(&conn, r, cache.WithExpiry(time.Second*30)) - err = c.QueryRow(&user, key, func(conn sqlx.SqlConn, v interface{}) error { + err = c.QueryRow(&user, key, func(conn sqlx.SqlConn, v any) error { ran = true user = value return nil @@ -426,7 +426,7 @@ func TestCachedConnQueryRowFromCache(t *testing.T) { var ran bool c := NewNodeConn(&conn, r, cache.WithExpiry(time.Second*30)) assert.Nil(t, c.SetCache(key, value)) - err = c.QueryRow(&user, key, func(conn sqlx.SqlConn, v interface{}) error { + err = c.QueryRow(&user, key, func(conn sqlx.SqlConn, v any) error { ran = true user = value return nil @@ -452,7 +452,7 @@ func TestQueryRowNotFound(t *testing.T) { var ran int c := NewNodeConn(&conn, r, cache.WithExpiry(time.Second*30)) for i := 0; i < 20; i++ { - err = c.QueryRow(&user, key, func(conn sqlx.SqlConn, v interface{}) error { + err = c.QueryRow(&user, key, func(conn sqlx.SqlConn, v any) error { ran++ return sql.ErrNoRows }) @@ -551,7 +551,7 @@ func TestQueryRowNoCache(t *testing.T) { ) var user string var ran bool - conn := dummySqlConn{queryRow: func(v interface{}, q string, args ...interface{}) error { + conn := dummySqlConn{queryRow: func(v any, q string, args ...any) error { user = value ran = true return nil @@ -583,10 +583,10 @@ func resetStats() { } type dummySqlConn struct { - queryRow func(interface{}, string, ...interface{}) error + queryRow func(any, string, ...any) error } -func (d dummySqlConn) ExecCtx(ctx context.Context, query string, args ...interface{}) (sql.Result, error) { +func (d dummySqlConn) ExecCtx(ctx context.Context, query string, args ...any) (sql.Result, error) { return nil, nil } @@ -594,15 +594,15 @@ func (d dummySqlConn) PrepareCtx(ctx context.Context, query string) (sqlx.StmtSe return nil, nil } -func (d dummySqlConn) QueryRowPartialCtx(ctx context.Context, v interface{}, query string, args ...interface{}) error { +func (d dummySqlConn) QueryRowPartialCtx(ctx context.Context, v any, query string, args ...any) error { return nil } -func (d dummySqlConn) QueryRowsCtx(ctx context.Context, v interface{}, query string, args ...interface{}) error { +func (d dummySqlConn) QueryRowsCtx(ctx context.Context, v any, query string, args ...any) error { return nil } -func (d dummySqlConn) QueryRowsPartialCtx(ctx context.Context, v interface{}, query string, args ...interface{}) error { +func (d dummySqlConn) QueryRowsPartialCtx(ctx context.Context, v any, query string, args ...any) error { return nil } @@ -610,7 +610,7 @@ func (d dummySqlConn) TransactCtx(ctx context.Context, fn func(context.Context, return nil } -func (d dummySqlConn) Exec(query string, args ...interface{}) (sql.Result, error) { +func (d dummySqlConn) Exec(query string, args ...any) (sql.Result, error) { return nil, nil } @@ -618,26 +618,26 @@ func (d dummySqlConn) Prepare(query string) (sqlx.StmtSession, error) { return nil, nil } -func (d dummySqlConn) QueryRow(v interface{}, query string, args ...interface{}) error { +func (d dummySqlConn) QueryRow(v any, query string, args ...any) error { return d.QueryRowCtx(context.Background(), v, query, args...) } -func (d dummySqlConn) QueryRowCtx(_ context.Context, v interface{}, query string, args ...interface{}) error { +func (d dummySqlConn) QueryRowCtx(_ context.Context, v any, query string, args ...any) error { if d.queryRow != nil { return d.queryRow(v, query, args...) } return nil } -func (d dummySqlConn) QueryRowPartial(v interface{}, query string, args ...interface{}) error { +func (d dummySqlConn) QueryRowPartial(v any, query string, args ...any) error { return nil } -func (d dummySqlConn) QueryRows(v interface{}, query string, args ...interface{}) error { +func (d dummySqlConn) QueryRows(v any, query string, args ...any) error { return nil } -func (d dummySqlConn) QueryRowsPartial(v interface{}, query string, args ...interface{}) error { +func (d dummySqlConn) QueryRowsPartial(v any, query string, args ...any) error { return nil } @@ -656,20 +656,20 @@ type trackedConn struct { transactValue bool } -func (c *trackedConn) Exec(query string, args ...interface{}) (sql.Result, error) { +func (c *trackedConn) Exec(query string, args ...any) (sql.Result, error) { return c.ExecCtx(context.Background(), query, args...) } -func (c *trackedConn) ExecCtx(ctx context.Context, query string, args ...interface{}) (sql.Result, error) { +func (c *trackedConn) ExecCtx(ctx context.Context, query string, args ...any) (sql.Result, error) { c.execValue = true return c.dummySqlConn.ExecCtx(ctx, query, args...) } -func (c *trackedConn) QueryRows(v interface{}, query string, args ...interface{}) error { +func (c *trackedConn) QueryRows(v any, query string, args ...any) error { return c.QueryRowsCtx(context.Background(), v, query, args...) } -func (c *trackedConn) QueryRowsCtx(ctx context.Context, v interface{}, query string, args ...interface{}) error { +func (c *trackedConn) QueryRowsCtx(ctx context.Context, v any, query string, args ...any) error { c.queryRowsValue = true return c.dummySqlConn.QueryRowsCtx(ctx, v, query, args...) } diff --git a/core/stores/sqlx/bulkinserter.go b/core/stores/sqlx/bulkinserter.go index a4a2d99a..789d1e80 100644 --- a/core/stores/sqlx/bulkinserter.go +++ b/core/stores/sqlx/bulkinserter.go @@ -64,7 +64,7 @@ func (bi *BulkInserter) Flush() { } // Insert inserts given args. -func (bi *BulkInserter) Insert(args ...interface{}) error { +func (bi *BulkInserter) Insert(args ...any) error { value, err := format(bi.stmt.valueFormat, args...) if err != nil { return err @@ -110,12 +110,12 @@ type dbInserter struct { resultHandler ResultHandler } -func (in *dbInserter) AddTask(task interface{}) bool { +func (in *dbInserter) AddTask(task any) bool { in.values = append(in.values, task.(string)) return len(in.values) >= maxBulkRows } -func (in *dbInserter) Execute(bulk interface{}) { +func (in *dbInserter) Execute(bulk any) { values := bulk.([]string) if len(values) == 0 { return @@ -135,7 +135,7 @@ func (in *dbInserter) Execute(bulk interface{}) { } } -func (in *dbInserter) RemoveAll() interface{} { +func (in *dbInserter) RemoveAll() any { values := in.values in.values = nil return values diff --git a/core/stores/sqlx/bulkinserter_test.go b/core/stores/sqlx/bulkinserter_test.go index 1c16a5b0..52348252 100644 --- a/core/stores/sqlx/bulkinserter_test.go +++ b/core/stores/sqlx/bulkinserter_test.go @@ -14,11 +14,11 @@ import ( type mockedConn struct { query string - args []interface{} + args []any execErr error } -func (c *mockedConn) ExecCtx(_ context.Context, query string, args ...interface{}) (sql.Result, error) { +func (c *mockedConn) ExecCtx(_ context.Context, query string, args ...any) (sql.Result, error) { c.query = query c.args = args return nil, c.execErr @@ -28,19 +28,19 @@ func (c *mockedConn) PrepareCtx(ctx context.Context, query string) (StmtSession, panic("implement me") } -func (c *mockedConn) QueryRowCtx(ctx context.Context, v interface{}, query string, args ...interface{}) error { +func (c *mockedConn) QueryRowCtx(ctx context.Context, v any, query string, args ...any) error { panic("implement me") } -func (c *mockedConn) QueryRowPartialCtx(ctx context.Context, v interface{}, query string, args ...interface{}) error { +func (c *mockedConn) QueryRowPartialCtx(ctx context.Context, v any, query string, args ...any) error { panic("implement me") } -func (c *mockedConn) QueryRowsCtx(ctx context.Context, v interface{}, query string, args ...interface{}) error { +func (c *mockedConn) QueryRowsCtx(ctx context.Context, v any, query string, args ...any) error { panic("implement me") } -func (c *mockedConn) QueryRowsPartialCtx(ctx context.Context, v interface{}, query string, args ...interface{}) error { +func (c *mockedConn) QueryRowsPartialCtx(ctx context.Context, v any, query string, args ...any) error { panic("implement me") } @@ -48,7 +48,7 @@ func (c *mockedConn) TransactCtx(ctx context.Context, fn func(context.Context, S panic("should not called") } -func (c *mockedConn) Exec(query string, args ...interface{}) (sql.Result, error) { +func (c *mockedConn) Exec(query string, args ...any) (sql.Result, error) { return c.ExecCtx(context.Background(), query, args...) } @@ -56,19 +56,19 @@ func (c *mockedConn) Prepare(query string) (StmtSession, error) { panic("should not called") } -func (c *mockedConn) QueryRow(v interface{}, query string, args ...interface{}) error { +func (c *mockedConn) QueryRow(v any, query string, args ...any) error { panic("should not called") } -func (c *mockedConn) QueryRowPartial(v interface{}, query string, args ...interface{}) error { +func (c *mockedConn) QueryRowPartial(v any, query string, args ...any) error { panic("should not called") } -func (c *mockedConn) QueryRows(v interface{}, query string, args ...interface{}) error { +func (c *mockedConn) QueryRows(v any, query string, args ...any) error { panic("should not called") } -func (c *mockedConn) QueryRowsPartial(v interface{}, query string, args ...interface{}) error { +func (c *mockedConn) QueryRowsPartial(v any, query string, args ...any) error { panic("should not called") } diff --git a/core/stores/sqlx/orm.go b/core/stores/sqlx/orm.go index d8c51b8d..b6e1b3bd 100644 --- a/core/stores/sqlx/orm.go +++ b/core/stores/sqlx/orm.go @@ -25,13 +25,13 @@ type rowsScanner interface { Columns() ([]string, error) Err() error Next() bool - Scan(v ...interface{}) error + Scan(v ...any) error } -func getTaggedFieldValueMap(v reflect.Value) (map[string]interface{}, error) { +func getTaggedFieldValueMap(v reflect.Value) (map[string]any, error) { rt := mapping.Deref(v.Type()) size := rt.NumField() - result := make(map[string]interface{}, size) + result := make(map[string]any, size) for i := 0; i < size; i++ { key := parseTagName(rt.Field(i)) @@ -61,7 +61,7 @@ func getTaggedFieldValueMap(v reflect.Value) (map[string]interface{}, error) { return result, nil } -func mapStructFieldsIntoSlice(v reflect.Value, columns []string, strict bool) ([]interface{}, error) { +func mapStructFieldsIntoSlice(v reflect.Value, columns []string, strict bool) ([]any, error) { fields := unwrapFields(v) if strict && len(columns) < len(fields) { return nil, ErrNotMatchDestination @@ -72,7 +72,7 @@ func mapStructFieldsIntoSlice(v reflect.Value, columns []string, strict bool) ([ return nil, err } - values := make([]interface{}, len(columns)) + values := make([]any, len(columns)) if len(taggedMap) == 0 { for i := 0; i < len(values); i++ { valueField := fields[i] @@ -98,7 +98,7 @@ func mapStructFieldsIntoSlice(v reflect.Value, columns []string, strict bool) ([ if tagged, ok := taggedMap[column]; ok { values[i] = tagged } else { - var anonymous interface{} + var anonymous any values[i] = &anonymous } } @@ -117,7 +117,7 @@ func parseTagName(field reflect.StructField) string { return options[0] } -func unmarshalRow(v interface{}, scanner rowsScanner, strict bool) error { +func unmarshalRow(v any, scanner rowsScanner, strict bool) error { if !scanner.Next() { if err := scanner.Err(); err != nil { return err @@ -160,7 +160,7 @@ func unmarshalRow(v interface{}, scanner rowsScanner, strict bool) error { } } -func unmarshalRows(v interface{}, scanner rowsScanner, strict bool) error { +func unmarshalRows(v any, scanner rowsScanner, strict bool) error { rv := reflect.ValueOf(v) if err := mapping.ValidatePtr(&rv); err != nil { return err @@ -180,7 +180,7 @@ func unmarshalRows(v interface{}, scanner rowsScanner, strict bool) error { rve.Set(reflect.Append(rve, reflect.Indirect(item))) } } - fillFn := func(value interface{}) error { + fillFn := func(value any) error { if rve.CanSet() { if err := scanner.Scan(value); err != nil { return err diff --git a/core/stores/sqlx/orm_test.go b/core/stores/sqlx/orm_test.go index a629d43d..c6066a76 100644 --- a/core/stores/sqlx/orm_test.go +++ b/core/stores/sqlx/orm_test.go @@ -1080,6 +1080,6 @@ func (m *mockedScanner) Next() bool { return false } -func (m *mockedScanner) Scan(v ...interface{}) error { +func (m *mockedScanner) Scan(v ...any) error { return m.scanErr } diff --git a/core/stores/sqlx/sqlconn.go b/core/stores/sqlx/sqlconn.go index 0118a38d..bc3eeea4 100644 --- a/core/stores/sqlx/sqlconn.go +++ b/core/stores/sqlx/sqlconn.go @@ -17,18 +17,18 @@ var ErrNotFound = sql.ErrNoRows type ( // Session stands for raw connections or transaction sessions Session interface { - Exec(query string, args ...interface{}) (sql.Result, error) - ExecCtx(ctx context.Context, query string, args ...interface{}) (sql.Result, error) + Exec(query string, args ...any) (sql.Result, error) + ExecCtx(ctx context.Context, query string, args ...any) (sql.Result, error) Prepare(query string) (StmtSession, error) PrepareCtx(ctx context.Context, query string) (StmtSession, error) - QueryRow(v interface{}, query string, args ...interface{}) error - QueryRowCtx(ctx context.Context, v interface{}, query string, args ...interface{}) error - QueryRowPartial(v interface{}, query string, args ...interface{}) error - QueryRowPartialCtx(ctx context.Context, v interface{}, query string, args ...interface{}) error - QueryRows(v interface{}, query string, args ...interface{}) error - QueryRowsCtx(ctx context.Context, v interface{}, query string, args ...interface{}) error - QueryRowsPartial(v interface{}, query string, args ...interface{}) error - QueryRowsPartialCtx(ctx context.Context, v interface{}, query string, args ...interface{}) error + QueryRow(v any, query string, args ...any) error + QueryRowCtx(ctx context.Context, v any, query string, args ...any) error + QueryRowPartial(v any, query string, args ...any) error + QueryRowPartialCtx(ctx context.Context, v any, query string, args ...any) error + QueryRows(v any, query string, args ...any) error + QueryRowsCtx(ctx context.Context, v any, query string, args ...any) error + QueryRowsPartial(v any, query string, args ...any) error + QueryRowsPartialCtx(ctx context.Context, v any, query string, args ...any) error } // SqlConn only stands for raw connections, so Transact method can be called. @@ -47,16 +47,16 @@ type ( // StmtSession interface represents a session that can be used to execute statements. StmtSession interface { Close() error - Exec(args ...interface{}) (sql.Result, error) - ExecCtx(ctx context.Context, args ...interface{}) (sql.Result, error) - QueryRow(v interface{}, args ...interface{}) error - QueryRowCtx(ctx context.Context, v interface{}, args ...interface{}) error - QueryRowPartial(v interface{}, args ...interface{}) error - QueryRowPartialCtx(ctx context.Context, v interface{}, args ...interface{}) error - QueryRows(v interface{}, args ...interface{}) error - QueryRowsCtx(ctx context.Context, v interface{}, args ...interface{}) error - QueryRowsPartial(v interface{}, args ...interface{}) error - QueryRowsPartialCtx(ctx context.Context, v interface{}, args ...interface{}) error + Exec(args ...any) (sql.Result, error) + ExecCtx(ctx context.Context, args ...any) (sql.Result, error) + QueryRow(v any, args ...any) error + QueryRowCtx(ctx context.Context, v any, args ...any) error + QueryRowPartial(v any, args ...any) error + QueryRowPartialCtx(ctx context.Context, v any, args ...any) error + QueryRows(v any, args ...any) error + QueryRowsCtx(ctx context.Context, v any, args ...any) error + QueryRowsPartial(v any, args ...any) error + QueryRowsPartialCtx(ctx context.Context, v any, args ...any) error } // thread-safe @@ -73,10 +73,10 @@ type ( connProvider func() (*sql.DB, error) sessionConn interface { - Exec(query string, args ...interface{}) (sql.Result, error) - ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) - Query(query string, args ...interface{}) (*sql.Rows, error) - QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) + Exec(query string, args ...any) (sql.Result, error) + ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error) + Query(query string, args ...any) (*sql.Rows, error) + QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error) } statement struct { @@ -85,10 +85,10 @@ type ( } stmtConn interface { - Exec(args ...interface{}) (sql.Result, error) - ExecContext(ctx context.Context, args ...interface{}) (sql.Result, error) - Query(args ...interface{}) (*sql.Rows, error) - QueryContext(ctx context.Context, args ...interface{}) (*sql.Rows, error) + Exec(args ...any) (sql.Result, error) + ExecContext(ctx context.Context, args ...any) (sql.Result, error) + Query(args ...any) (*sql.Rows, error) + QueryContext(ctx context.Context, args ...any) (*sql.Rows, error) } ) @@ -131,11 +131,11 @@ func NewSqlConnFromDB(db *sql.DB, opts ...SqlOption) SqlConn { return conn } -func (db *commonSqlConn) Exec(q string, args ...interface{}) (result sql.Result, err error) { +func (db *commonSqlConn) Exec(q string, args ...any) (result sql.Result, err error) { return db.ExecCtx(context.Background(), q, args...) } -func (db *commonSqlConn) ExecCtx(ctx context.Context, q string, args ...interface{}) ( +func (db *commonSqlConn) ExecCtx(ctx context.Context, q string, args ...any) ( result sql.Result, err error) { ctx, span := startSpan(ctx, "Exec") defer func() { @@ -196,12 +196,12 @@ func (db *commonSqlConn) PrepareCtx(ctx context.Context, query string) (stmt Stm return } -func (db *commonSqlConn) QueryRow(v interface{}, q string, args ...interface{}) error { +func (db *commonSqlConn) QueryRow(v any, q string, args ...any) error { return db.QueryRowCtx(context.Background(), v, q, args...) } -func (db *commonSqlConn) QueryRowCtx(ctx context.Context, v interface{}, q string, - args ...interface{}) (err error) { +func (db *commonSqlConn) QueryRowCtx(ctx context.Context, v any, q string, + args ...any) (err error) { ctx, span := startSpan(ctx, "QueryRow") defer func() { endSpan(span, err) @@ -212,12 +212,12 @@ func (db *commonSqlConn) QueryRowCtx(ctx context.Context, v interface{}, q strin }, q, args...) } -func (db *commonSqlConn) QueryRowPartial(v interface{}, q string, args ...interface{}) error { +func (db *commonSqlConn) QueryRowPartial(v any, q string, args ...any) error { return db.QueryRowPartialCtx(context.Background(), v, q, args...) } -func (db *commonSqlConn) QueryRowPartialCtx(ctx context.Context, v interface{}, - q string, args ...interface{}) (err error) { +func (db *commonSqlConn) QueryRowPartialCtx(ctx context.Context, v any, + q string, args ...any) (err error) { ctx, span := startSpan(ctx, "QueryRowPartial") defer func() { endSpan(span, err) @@ -228,12 +228,12 @@ func (db *commonSqlConn) QueryRowPartialCtx(ctx context.Context, v interface{}, }, q, args...) } -func (db *commonSqlConn) QueryRows(v interface{}, q string, args ...interface{}) error { +func (db *commonSqlConn) QueryRows(v any, q string, args ...any) error { return db.QueryRowsCtx(context.Background(), v, q, args...) } -func (db *commonSqlConn) QueryRowsCtx(ctx context.Context, v interface{}, q string, - args ...interface{}) (err error) { +func (db *commonSqlConn) QueryRowsCtx(ctx context.Context, v any, q string, + args ...any) (err error) { ctx, span := startSpan(ctx, "QueryRows") defer func() { endSpan(span, err) @@ -244,12 +244,12 @@ func (db *commonSqlConn) QueryRowsCtx(ctx context.Context, v interface{}, q stri }, q, args...) } -func (db *commonSqlConn) QueryRowsPartial(v interface{}, q string, args ...interface{}) error { +func (db *commonSqlConn) QueryRowsPartial(v any, q string, args ...any) error { return db.QueryRowsPartialCtx(context.Background(), v, q, args...) } -func (db *commonSqlConn) QueryRowsPartialCtx(ctx context.Context, v interface{}, - q string, args ...interface{}) (err error) { +func (db *commonSqlConn) QueryRowsPartialCtx(ctx context.Context, v any, + q string, args ...any) (err error) { ctx, span := startSpan(ctx, "QueryRowsPartial") defer func() { endSpan(span, err) @@ -296,7 +296,7 @@ func (db *commonSqlConn) acceptable(err error) bool { } func (db *commonSqlConn) queryRows(ctx context.Context, scanner func(*sql.Rows) error, - q string, args ...interface{}) (err error) { + q string, args ...any) (err error) { var qerr error err = db.brk.DoWithAcceptable(func() error { conn, err := db.connProv() @@ -323,11 +323,11 @@ func (s statement) Close() error { return s.stmt.Close() } -func (s statement) Exec(args ...interface{}) (sql.Result, error) { +func (s statement) Exec(args ...any) (sql.Result, error) { return s.ExecCtx(context.Background(), args...) } -func (s statement) ExecCtx(ctx context.Context, args ...interface{}) (result sql.Result, err error) { +func (s statement) ExecCtx(ctx context.Context, args ...any) (result sql.Result, err error) { ctx, span := startSpan(ctx, "Exec") defer func() { endSpan(span, err) @@ -336,11 +336,11 @@ func (s statement) ExecCtx(ctx context.Context, args ...interface{}) (result sql return execStmt(ctx, s.stmt, s.query, args...) } -func (s statement) QueryRow(v interface{}, args ...interface{}) error { +func (s statement) QueryRow(v any, args ...any) error { return s.QueryRowCtx(context.Background(), v, args...) } -func (s statement) QueryRowCtx(ctx context.Context, v interface{}, args ...interface{}) (err error) { +func (s statement) QueryRowCtx(ctx context.Context, v any, args ...any) (err error) { ctx, span := startSpan(ctx, "QueryRow") defer func() { endSpan(span, err) @@ -351,11 +351,11 @@ func (s statement) QueryRowCtx(ctx context.Context, v interface{}, args ...inter }, s.query, args...) } -func (s statement) QueryRowPartial(v interface{}, args ...interface{}) error { +func (s statement) QueryRowPartial(v any, args ...any) error { return s.QueryRowPartialCtx(context.Background(), v, args...) } -func (s statement) QueryRowPartialCtx(ctx context.Context, v interface{}, args ...interface{}) (err error) { +func (s statement) QueryRowPartialCtx(ctx context.Context, v any, args ...any) (err error) { ctx, span := startSpan(ctx, "QueryRowPartial") defer func() { endSpan(span, err) @@ -366,11 +366,11 @@ func (s statement) QueryRowPartialCtx(ctx context.Context, v interface{}, args . }, s.query, args...) } -func (s statement) QueryRows(v interface{}, args ...interface{}) error { +func (s statement) QueryRows(v any, args ...any) error { return s.QueryRowsCtx(context.Background(), v, args...) } -func (s statement) QueryRowsCtx(ctx context.Context, v interface{}, args ...interface{}) (err error) { +func (s statement) QueryRowsCtx(ctx context.Context, v any, args ...any) (err error) { ctx, span := startSpan(ctx, "QueryRows") defer func() { endSpan(span, err) @@ -381,11 +381,11 @@ func (s statement) QueryRowsCtx(ctx context.Context, v interface{}, args ...inte }, s.query, args...) } -func (s statement) QueryRowsPartial(v interface{}, args ...interface{}) error { +func (s statement) QueryRowsPartial(v any, args ...any) error { return s.QueryRowsPartialCtx(context.Background(), v, args...) } -func (s statement) QueryRowsPartialCtx(ctx context.Context, v interface{}, args ...interface{}) (err error) { +func (s statement) QueryRowsPartialCtx(ctx context.Context, v any, args ...any) (err error) { ctx, span := startSpan(ctx, "QueryRowsPartial") defer func() { endSpan(span, err) diff --git a/core/stores/sqlx/stmt.go b/core/stores/sqlx/stmt.go index 35796b1b..5dc206a5 100644 --- a/core/stores/sqlx/stmt.go +++ b/core/stores/sqlx/stmt.go @@ -34,7 +34,7 @@ func SetSlowThreshold(threshold time.Duration) { slowThreshold.Set(threshold) } -func exec(ctx context.Context, conn sessionConn, q string, args ...interface{}) (sql.Result, error) { +func exec(ctx context.Context, conn sessionConn, q string, args ...any) (sql.Result, error) { guard := newGuard("exec") if err := guard.start(q, args...); err != nil { return nil, err @@ -46,7 +46,7 @@ func exec(ctx context.Context, conn sessionConn, q string, args ...interface{}) return result, err } -func execStmt(ctx context.Context, conn stmtConn, q string, args ...interface{}) (sql.Result, error) { +func execStmt(ctx context.Context, conn stmtConn, q string, args ...any) (sql.Result, error) { guard := newGuard("execStmt") if err := guard.start(q, args...); err != nil { return nil, err @@ -59,7 +59,7 @@ func execStmt(ctx context.Context, conn stmtConn, q string, args ...interface{}) } func query(ctx context.Context, conn sessionConn, scanner func(*sql.Rows) error, - q string, args ...interface{}) error { + q string, args ...any) error { guard := newGuard("query") if err := guard.start(q, args...); err != nil { return err @@ -76,7 +76,7 @@ func query(ctx context.Context, conn sessionConn, scanner func(*sql.Rows) error, } func queryStmt(ctx context.Context, conn stmtConn, scanner func(*sql.Rows) error, - q string, args ...interface{}) error { + q string, args ...any) error { guard := newGuard("queryStmt") if err := guard.start(q, args...); err != nil { return err @@ -94,7 +94,7 @@ func queryStmt(ctx context.Context, conn stmtConn, scanner func(*sql.Rows) error type ( sqlGuard interface { - start(q string, args ...interface{}) error + start(q string, args ...any) error finish(ctx context.Context, err error) } @@ -117,7 +117,7 @@ func newGuard(command string) sqlGuard { return nilGuard{} } -func (n nilGuard) start(_ string, _ ...interface{}) error { +func (n nilGuard) start(_ string, _ ...any) error { return nil } @@ -139,7 +139,7 @@ func (e *realSqlGuard) finish(ctx context.Context, err error) { metricReqDur.Observe(int64(duration/time.Millisecond), e.command) } -func (e *realSqlGuard) start(q string, args ...interface{}) error { +func (e *realSqlGuard) start(q string, args ...any) error { stmt, err := format(q, args...) if err != nil { return err diff --git a/core/stores/sqlx/stmt_test.go b/core/stores/sqlx/stmt_test.go index 0647e9c1..215bf2b2 100644 --- a/core/stores/sqlx/stmt_test.go +++ b/core/stores/sqlx/stmt_test.go @@ -16,7 +16,7 @@ func TestStmt_exec(t *testing.T) { tests := []struct { name string query string - args []interface{} + args []any delay bool hasError bool err error @@ -26,28 +26,28 @@ func TestStmt_exec(t *testing.T) { { name: "normal", query: "select user from users where id=?", - args: []interface{}{1}, + args: []any{1}, lastInsertId: 1, rowsAffected: 2, }, { name: "exec error", query: "select user from users where id=?", - args: []interface{}{1}, + args: []any{1}, hasError: true, err: errors.New("exec"), }, { name: "exec more args error", query: "select user from users where id=? and name=?", - args: []interface{}{1}, + args: []any{1}, hasError: true, err: errors.New("exec"), }, { name: "slowcall", query: "select user from users where id=?", - args: []interface{}{1}, + args: []any{1}, delay: true, lastInsertId: 1, rowsAffected: 2, @@ -56,8 +56,8 @@ func TestStmt_exec(t *testing.T) { for _, test := range tests { test := test - fns := []func(args ...interface{}) (sql.Result, error){ - func(args ...interface{}) (sql.Result, error) { + fns := []func(args ...any) (sql.Result, error){ + func(args ...any) (sql.Result, error) { return exec(context.Background(), &mockedSessionConn{ lastInsertId: test.lastInsertId, rowsAffected: test.rowsAffected, @@ -65,7 +65,7 @@ func TestStmt_exec(t *testing.T) { delay: test.delay, }, test.query, args...) }, - func(args ...interface{}) (sql.Result, error) { + func(args ...any) (sql.Result, error) { return execStmt(context.Background(), &mockedStmtConn{ lastInsertId: test.lastInsertId, rowsAffected: test.rowsAffected, @@ -102,7 +102,7 @@ func TestStmt_query(t *testing.T) { tests := []struct { name string query string - args []interface{} + args []any delay bool hasError bool err error @@ -110,34 +110,34 @@ func TestStmt_query(t *testing.T) { { name: "normal", query: "select user from users where id=?", - args: []interface{}{1}, + args: []any{1}, }, { name: "query error", query: "select user from users where id=?", - args: []interface{}{1}, + args: []any{1}, hasError: true, err: errors.New("exec"), }, { name: "query more args error", query: "select user from users where id=? and name=?", - args: []interface{}{1}, + args: []any{1}, hasError: true, err: errors.New("exec"), }, { name: "slowcall", query: "select user from users where id=?", - args: []interface{}{1}, + args: []any{1}, delay: true, }, } for _, test := range tests { test := test - fns := []func(args ...interface{}) error{ - func(args ...interface{}) error { + fns := []func(args ...any) error{ + func(args ...any) error { return query(context.Background(), &mockedSessionConn{ err: test.err, delay: test.delay, @@ -145,7 +145,7 @@ func TestStmt_query(t *testing.T) { return nil }, test.query, args...) }, - func(args ...interface{}) error { + func(args ...any) error { return queryStmt(context.Background(), &mockedStmtConn{ err: test.err, delay: test.delay, @@ -226,11 +226,11 @@ type mockedSessionConn struct { delay bool } -func (m *mockedSessionConn) Exec(query string, args ...interface{}) (sql.Result, error) { +func (m *mockedSessionConn) Exec(query string, args ...any) (sql.Result, error) { return m.ExecContext(context.Background(), query, args...) } -func (m *mockedSessionConn) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) { +func (m *mockedSessionConn) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error) { if m.delay { time.Sleep(defaultSlowThreshold + time.Millisecond) } @@ -240,11 +240,11 @@ func (m *mockedSessionConn) ExecContext(ctx context.Context, query string, args }, m.err } -func (m *mockedSessionConn) Query(query string, args ...interface{}) (*sql.Rows, error) { +func (m *mockedSessionConn) Query(query string, args ...any) (*sql.Rows, error) { return m.QueryContext(context.Background(), query, args...) } -func (m *mockedSessionConn) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) { +func (m *mockedSessionConn) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error) { if m.delay { time.Sleep(defaultSlowThreshold + time.Millisecond) } @@ -263,11 +263,11 @@ type mockedStmtConn struct { delay bool } -func (m *mockedStmtConn) Exec(args ...interface{}) (sql.Result, error) { +func (m *mockedStmtConn) Exec(args ...any) (sql.Result, error) { return m.ExecContext(context.Background(), args...) } -func (m *mockedStmtConn) ExecContext(_ context.Context, _ ...interface{}) (sql.Result, error) { +func (m *mockedStmtConn) ExecContext(_ context.Context, _ ...any) (sql.Result, error) { if m.delay { time.Sleep(defaultSlowThreshold + time.Millisecond) } @@ -277,11 +277,11 @@ func (m *mockedStmtConn) ExecContext(_ context.Context, _ ...interface{}) (sql.R }, m.err } -func (m *mockedStmtConn) Query(args ...interface{}) (*sql.Rows, error) { +func (m *mockedStmtConn) Query(args ...any) (*sql.Rows, error) { return m.QueryContext(context.Background(), args...) } -func (m *mockedStmtConn) QueryContext(_ context.Context, _ ...interface{}) (*sql.Rows, error) { +func (m *mockedStmtConn) QueryContext(_ context.Context, _ ...any) (*sql.Rows, error) { if m.delay { time.Sleep(defaultSlowThreshold + time.Millisecond) } diff --git a/core/stores/sqlx/tx.go b/core/stores/sqlx/tx.go index 0ddd7e41..9c586c2e 100644 --- a/core/stores/sqlx/tx.go +++ b/core/stores/sqlx/tx.go @@ -26,11 +26,11 @@ func NewSessionFromTx(tx *sql.Tx) Session { return txSession{Tx: tx} } -func (t txSession) Exec(q string, args ...interface{}) (sql.Result, error) { +func (t txSession) Exec(q string, args ...any) (sql.Result, error) { return t.ExecCtx(context.Background(), q, args...) } -func (t txSession) ExecCtx(ctx context.Context, q string, args ...interface{}) (result sql.Result, err error) { +func (t txSession) ExecCtx(ctx context.Context, q string, args ...any) (result sql.Result, err error) { ctx, span := startSpan(ctx, "Exec") defer func() { endSpan(span, err) @@ -62,11 +62,11 @@ func (t txSession) PrepareCtx(ctx context.Context, q string) (stmtSession StmtSe }, nil } -func (t txSession) QueryRow(v interface{}, q string, args ...interface{}) error { +func (t txSession) QueryRow(v any, q string, args ...any) error { return t.QueryRowCtx(context.Background(), v, q, args...) } -func (t txSession) QueryRowCtx(ctx context.Context, v interface{}, q string, args ...interface{}) (err error) { +func (t txSession) QueryRowCtx(ctx context.Context, v any, q string, args ...any) (err error) { ctx, span := startSpan(ctx, "QueryRow") defer func() { endSpan(span, err) @@ -77,12 +77,12 @@ func (t txSession) QueryRowCtx(ctx context.Context, v interface{}, q string, arg }, q, args...) } -func (t txSession) QueryRowPartial(v interface{}, q string, args ...interface{}) error { +func (t txSession) QueryRowPartial(v any, q string, args ...any) error { return t.QueryRowPartialCtx(context.Background(), v, q, args...) } -func (t txSession) QueryRowPartialCtx(ctx context.Context, v interface{}, q string, - args ...interface{}) (err error) { +func (t txSession) QueryRowPartialCtx(ctx context.Context, v any, q string, + args ...any) (err error) { ctx, span := startSpan(ctx, "QueryRowPartial") defer func() { endSpan(span, err) @@ -93,11 +93,11 @@ func (t txSession) QueryRowPartialCtx(ctx context.Context, v interface{}, q stri }, q, args...) } -func (t txSession) QueryRows(v interface{}, q string, args ...interface{}) error { +func (t txSession) QueryRows(v any, q string, args ...any) error { return t.QueryRowsCtx(context.Background(), v, q, args...) } -func (t txSession) QueryRowsCtx(ctx context.Context, v interface{}, q string, args ...interface{}) (err error) { +func (t txSession) QueryRowsCtx(ctx context.Context, v any, q string, args ...any) (err error) { ctx, span := startSpan(ctx, "QueryRows") defer func() { endSpan(span, err) @@ -108,12 +108,12 @@ func (t txSession) QueryRowsCtx(ctx context.Context, v interface{}, q string, ar }, q, args...) } -func (t txSession) QueryRowsPartial(v interface{}, q string, args ...interface{}) error { +func (t txSession) QueryRowsPartial(v any, q string, args ...any) error { return t.QueryRowsPartialCtx(context.Background(), v, q, args...) } -func (t txSession) QueryRowsPartialCtx(ctx context.Context, v interface{}, q string, - args ...interface{}) (err error) { +func (t txSession) QueryRowsPartialCtx(ctx context.Context, v any, q string, + args ...any) (err error) { ctx, span := startSpan(ctx, "QueryRowsPartial") defer func() { endSpan(span, err) diff --git a/core/stores/sqlx/tx_test.go b/core/stores/sqlx/tx_test.go index 297f0562..9dd11a10 100644 --- a/core/stores/sqlx/tx_test.go +++ b/core/stores/sqlx/tx_test.go @@ -23,11 +23,11 @@ func (mt *mockTx) Commit() error { return nil } -func (mt *mockTx) Exec(q string, args ...interface{}) (sql.Result, error) { +func (mt *mockTx) Exec(q string, args ...any) (sql.Result, error) { return nil, nil } -func (mt *mockTx) ExecCtx(ctx context.Context, query string, args ...interface{}) (sql.Result, error) { +func (mt *mockTx) ExecCtx(ctx context.Context, query string, args ...any) (sql.Result, error) { return nil, nil } @@ -39,35 +39,35 @@ func (mt *mockTx) PrepareCtx(ctx context.Context, query string) (StmtSession, er return nil, nil } -func (mt *mockTx) QueryRow(v interface{}, q string, args ...interface{}) error { +func (mt *mockTx) QueryRow(v any, q string, args ...any) error { return nil } -func (mt *mockTx) QueryRowCtx(ctx context.Context, v interface{}, query string, args ...interface{}) error { +func (mt *mockTx) QueryRowCtx(ctx context.Context, v any, query string, args ...any) error { return nil } -func (mt *mockTx) QueryRowPartial(v interface{}, q string, args ...interface{}) error { +func (mt *mockTx) QueryRowPartial(v any, q string, args ...any) error { return nil } -func (mt *mockTx) QueryRowPartialCtx(ctx context.Context, v interface{}, query string, args ...interface{}) error { +func (mt *mockTx) QueryRowPartialCtx(ctx context.Context, v any, query string, args ...any) error { return nil } -func (mt *mockTx) QueryRows(v interface{}, q string, args ...interface{}) error { +func (mt *mockTx) QueryRows(v any, q string, args ...any) error { return nil } -func (mt *mockTx) QueryRowsCtx(ctx context.Context, v interface{}, query string, args ...interface{}) error { +func (mt *mockTx) QueryRowsCtx(ctx context.Context, v any, query string, args ...any) error { return nil } -func (mt *mockTx) QueryRowsPartial(v interface{}, q string, args ...interface{}) error { +func (mt *mockTx) QueryRowsPartial(v any, q string, args ...any) error { return nil } -func (mt *mockTx) QueryRowsPartialCtx(ctx context.Context, v interface{}, query string, args ...interface{}) error { +func (mt *mockTx) QueryRowsPartialCtx(ctx context.Context, v any, query string, args ...any) error { return nil } diff --git a/core/stores/sqlx/utils.go b/core/stores/sqlx/utils.go index 58428ecc..1bdcb684 100644 --- a/core/stores/sqlx/utils.go +++ b/core/stores/sqlx/utils.go @@ -51,7 +51,7 @@ func escape(input string) string { return b.String() } -func format(query string, args ...interface{}) (string, error) { +func format(query string, args ...any) (string, error) { numArgs := len(args) if numArgs == 0 { return query, nil @@ -141,7 +141,7 @@ func logSqlError(ctx context.Context, stmt string, err error) { } } -func writeValue(buf *strings.Builder, arg interface{}) { +func writeValue(buf *strings.Builder, arg any) { switch v := arg.(type) { case bool: if v { diff --git a/core/stores/sqlx/utils_test.go b/core/stores/sqlx/utils_test.go index f09e5ae4..437595ed 100644 --- a/core/stores/sqlx/utils_test.go +++ b/core/stores/sqlx/utils_test.go @@ -34,92 +34,92 @@ func TestFormat(t *testing.T) { tests := []struct { name string query string - args []interface{} + args []any expect string hasErr bool }{ { name: "mysql normal", query: "select name, age from users where bool=? and phone=?", - args: []interface{}{true, "133"}, + args: []any{true, "133"}, expect: "select name, age from users where bool=1 and phone='133'", }, { name: "mysql normal", query: "select name, age from users where bool=? and phone=?", - args: []interface{}{false, "133"}, + args: []any{false, "133"}, expect: "select name, age from users where bool=0 and phone='133'", }, { name: "pg normal", query: "select name, age from users where bool=$1 and phone=$2", - args: []interface{}{true, "133"}, + args: []any{true, "133"}, expect: "select name, age from users where bool=1 and phone='133'", }, { name: "pg normal reverse", query: "select name, age from users where bool=$2 and phone=$1", - args: []interface{}{"133", false}, + args: []any{"133", false}, expect: "select name, age from users where bool=0 and phone='133'", }, { name: "pg error not number", query: "select name, age from users where bool=$a and phone=$1", - args: []interface{}{"133", false}, + args: []any{"133", false}, hasErr: true, }, { name: "pg error more args", query: "select name, age from users where bool=$2 and phone=$1 and nickname=$3", - args: []interface{}{"133", false}, + args: []any{"133", false}, hasErr: true, }, { name: "oracle normal", query: "select name, age from users where bool=:1 and phone=:2", - args: []interface{}{true, "133"}, + args: []any{true, "133"}, expect: "select name, age from users where bool=1 and phone='133'", }, { name: "oracle normal reverse", query: "select name, age from users where bool=:2 and phone=:1", - args: []interface{}{"133", false}, + args: []any{"133", false}, expect: "select name, age from users where bool=0 and phone='133'", }, { name: "oracle error not number", query: "select name, age from users where bool=:a and phone=:1", - args: []interface{}{"133", false}, + args: []any{"133", false}, hasErr: true, }, { name: "oracle error more args", query: "select name, age from users where bool=:2 and phone=:1 and nickname=:3", - args: []interface{}{"133", false}, + args: []any{"133", false}, hasErr: true, }, { name: "select with date", query: "select * from user where date='2006-01-02 15:04:05' and name=:1", - args: []interface{}{"foo"}, + args: []any{"foo"}, expect: "select * from user where date='2006-01-02 15:04:05' and name='foo'", }, { name: "select with date and escape", query: `select * from user where date=' 2006-01-02 15:04:05 \'' and name=:1`, - args: []interface{}{"foo"}, + args: []any{"foo"}, expect: `select * from user where date=' 2006-01-02 15:04:05 \'' and name='foo'`, }, { name: "select with date and bad arg", query: `select * from user where date='2006-01-02 15:04:05 \'' and name=:a`, - args: []interface{}{"foo"}, + args: []any{"foo"}, hasErr: true, }, { name: "select with date and escape error", query: `select * from user where date='2006-01-02 15:04:05 \`, - args: []interface{}{"foo"}, + args: []any{"foo"}, hasErr: true, }, } diff --git a/core/syncx/immutableresource.go b/core/syncx/immutableresource.go index facf7b26..dd9e4733 100644 --- a/core/syncx/immutableresource.go +++ b/core/syncx/immutableresource.go @@ -15,8 +15,8 @@ type ( // An ImmutableResource is used to manage an immutable resource. ImmutableResource struct { - fetch func() (interface{}, error) - resource interface{} + fetch func() (any, error) + resource any err error lock sync.RWMutex refreshInterval time.Duration @@ -25,7 +25,7 @@ type ( ) // NewImmutableResource returns an ImmutableResource. -func NewImmutableResource(fn func() (interface{}, error), opts ...ImmutableResourceOption) *ImmutableResource { +func NewImmutableResource(fn func() (any, error), opts ...ImmutableResourceOption) *ImmutableResource { // cannot use executors.LessExecutor because of cycle imports ir := ImmutableResource{ fetch: fn, @@ -39,7 +39,7 @@ func NewImmutableResource(fn func() (interface{}, error), opts ...ImmutableResou } // Get gets the immutable resource, fetches automatically if not loaded. -func (ir *ImmutableResource) Get() (interface{}, error) { +func (ir *ImmutableResource) Get() (any, error) { ir.lock.RLock() resource := ir.resource ir.lock.RUnlock() diff --git a/core/syncx/immutableresource_test.go b/core/syncx/immutableresource_test.go index e76ecb48..8aec6b93 100644 --- a/core/syncx/immutableresource_test.go +++ b/core/syncx/immutableresource_test.go @@ -10,7 +10,7 @@ import ( func TestImmutableResource(t *testing.T) { var count int - r := NewImmutableResource(func() (interface{}, error) { + r := NewImmutableResource(func() (any, error) { count++ return "hello", nil }) @@ -29,7 +29,7 @@ func TestImmutableResource(t *testing.T) { func TestImmutableResourceError(t *testing.T) { var count int - r := NewImmutableResource(func() (interface{}, error) { + r := NewImmutableResource(func() (any, error) { count++ return nil, errors.New("any") }) @@ -58,7 +58,7 @@ func TestImmutableResourceError(t *testing.T) { func TestImmutableResourceErrorRefreshAlways(t *testing.T) { var count int - r := NewImmutableResource(func() (interface{}, error) { + r := NewImmutableResource(func() (any, error) { count++ return nil, errors.New("any") }, WithRefreshIntervalOnFailure(0)) diff --git a/core/syncx/lockedcalls.go b/core/syncx/lockedcalls.go index 3b7f1b3f..ffe47d1d 100644 --- a/core/syncx/lockedcalls.go +++ b/core/syncx/lockedcalls.go @@ -10,7 +10,7 @@ type ( // A ------->calls F with key and executes<------->returns // B ------------------>calls F with key<--------->executes<---->returns LockedCalls interface { - Do(key string, fn func() (interface{}, error)) (interface{}, error) + Do(key string, fn func() (any, error)) (any, error) } lockedGroup struct { @@ -26,7 +26,7 @@ func NewLockedCalls() LockedCalls { } } -func (lg *lockedGroup) Do(key string, fn func() (interface{}, error)) (interface{}, error) { +func (lg *lockedGroup) Do(key string, fn func() (any, error)) (any, error) { begin: lg.mu.Lock() if wg, ok := lg.m[key]; ok { @@ -38,7 +38,7 @@ begin: return lg.makeCall(key, fn) } -func (lg *lockedGroup) makeCall(key string, fn func() (interface{}, error)) (interface{}, error) { +func (lg *lockedGroup) makeCall(key string, fn func() (any, error)) (any, error) { var wg sync.WaitGroup wg.Add(1) lg.m[key] = &wg diff --git a/core/syncx/lockedcalls_test.go b/core/syncx/lockedcalls_test.go index 8e812807..3ae0debc 100644 --- a/core/syncx/lockedcalls_test.go +++ b/core/syncx/lockedcalls_test.go @@ -10,7 +10,7 @@ import ( func TestLockedCallDo(t *testing.T) { g := NewLockedCalls() - v, err := g.Do("key", func() (interface{}, error) { + v, err := g.Do("key", func() (any, error) { return "bar", nil }) if got, want := fmt.Sprintf("%v (%T)", v, v), "bar (string)"; got != want { @@ -24,7 +24,7 @@ func TestLockedCallDo(t *testing.T) { func TestLockedCallDoErr(t *testing.T) { g := NewLockedCalls() someErr := errors.New("some error") - v, err := g.Do("key", func() (interface{}, error) { + v, err := g.Do("key", func() (any, error) { return nil, someErr }) if err != someErr { @@ -39,7 +39,7 @@ func TestLockedCallDoDupSuppress(t *testing.T) { g := NewLockedCalls() c := make(chan string) var calls int - fn := func() (interface{}, error) { + fn := func() (any, error) { calls++ ret := calls <-c diff --git a/core/syncx/managedresource.go b/core/syncx/managedresource.go index 7c3fd693..018e4b58 100644 --- a/core/syncx/managedresource.go +++ b/core/syncx/managedresource.go @@ -4,14 +4,14 @@ import "sync" // A ManagedResource is used to manage a resource that might be broken and refetched, like a connection. type ManagedResource struct { - resource interface{} + resource any lock sync.RWMutex - generate func() interface{} - equals func(a, b interface{}) bool + generate func() any + equals func(a, b any) bool } // NewManagedResource returns a ManagedResource. -func NewManagedResource(generate func() interface{}, equals func(a, b interface{}) bool) *ManagedResource { +func NewManagedResource(generate func() any, equals func(a, b any) bool) *ManagedResource { return &ManagedResource{ generate: generate, equals: equals, @@ -19,7 +19,7 @@ func NewManagedResource(generate func() interface{}, equals func(a, b interface{ } // MarkBroken marks the resource broken. -func (mr *ManagedResource) MarkBroken(resource interface{}) { +func (mr *ManagedResource) MarkBroken(resource any) { mr.lock.Lock() defer mr.lock.Unlock() @@ -29,7 +29,7 @@ func (mr *ManagedResource) MarkBroken(resource interface{}) { } // Take takes the resource, if not loaded, generates it. -func (mr *ManagedResource) Take() interface{} { +func (mr *ManagedResource) Take() any { mr.lock.RLock() resource := mr.resource mr.lock.RUnlock() diff --git a/core/syncx/managedresource_test.go b/core/syncx/managedresource_test.go index 9f8b15df..ebcb18d1 100644 --- a/core/syncx/managedresource_test.go +++ b/core/syncx/managedresource_test.go @@ -9,9 +9,9 @@ import ( func TestManagedResource(t *testing.T) { var count int32 - resource := NewManagedResource(func() interface{} { + resource := NewManagedResource(func() any { return atomic.AddInt32(&count, 1) - }, func(a, b interface{}) bool { + }, func(a, b any) bool { return a == b }) diff --git a/core/syncx/pool.go b/core/syncx/pool.go index d990779c..c84d8310 100644 --- a/core/syncx/pool.go +++ b/core/syncx/pool.go @@ -12,7 +12,7 @@ type ( PoolOption func(*Pool) node struct { - item interface{} + item any next *node lastUsed time.Duration } @@ -29,13 +29,13 @@ type ( lock sync.Locker cond *sync.Cond head *node - create func() interface{} - destroy func(interface{}) + create func() any + destroy func(any) } ) // NewPool returns a Pool. -func NewPool(n int, create func() interface{}, destroy func(interface{}), opts ...PoolOption) *Pool { +func NewPool(n int, create func() any, destroy func(any), opts ...PoolOption) *Pool { if n <= 0 { panic("pool size can't be negative or zero") } @@ -57,7 +57,7 @@ func NewPool(n int, create func() interface{}, destroy func(interface{}), opts . } // Get gets a resource. -func (p *Pool) Get() interface{} { +func (p *Pool) Get() any { p.lock.Lock() defer p.lock.Unlock() @@ -84,7 +84,7 @@ func (p *Pool) Get() interface{} { } // Put puts a resource back. -func (p *Pool) Put(x interface{}) { +func (p *Pool) Put(x any) { if x == nil { return } diff --git a/core/syncx/pool_test.go b/core/syncx/pool_test.go index fa4fcca7..19c73934 100644 --- a/core/syncx/pool_test.go +++ b/core/syncx/pool_test.go @@ -75,7 +75,7 @@ func TestPoolPopTooMany(t *testing.T) { func TestPoolPopFirst(t *testing.T) { var value int32 - stack := NewPool(limit, func() interface{} { + stack := NewPool(limit, func() any { return atomic.AddInt32(&value, 1) }, destroy) @@ -88,7 +88,7 @@ func TestPoolPopFirst(t *testing.T) { func TestPoolWithMaxAge(t *testing.T) { var value int32 - stack := NewPool(limit, func() interface{} { + stack := NewPool(limit, func() any { return atomic.AddInt32(&value, 1) }, destroy, WithMaxAge(time.Millisecond)) @@ -107,9 +107,9 @@ func TestNewPoolPanics(t *testing.T) { }) } -func create() interface{} { +func create() any { return 1 } -func destroy(_ interface{}) { +func destroy(_ any) { } diff --git a/core/syncx/resourcemanager.go b/core/syncx/resourcemanager.go index f556f924..66390c8a 100644 --- a/core/syncx/resourcemanager.go +++ b/core/syncx/resourcemanager.go @@ -43,7 +43,7 @@ func (manager *ResourceManager) Close() error { // GetResource returns the resource associated with given key. func (manager *ResourceManager) GetResource(key string, create func() (io.Closer, error)) (io.Closer, error) { - val, err := manager.singleFlight.Do(key, func() (interface{}, error) { + val, err := manager.singleFlight.Do(key, func() (any, error) { manager.lock.RLock() resource, ok := manager.resources[key] manager.lock.RUnlock() diff --git a/core/syncx/singleflight.go b/core/syncx/singleflight.go index 92ae3ada..cbe62c62 100644 --- a/core/syncx/singleflight.go +++ b/core/syncx/singleflight.go @@ -10,13 +10,13 @@ type ( // A ------->calls F with key<------------------->returns val // B --------------------->calls F with key------>returns val SingleFlight interface { - Do(key string, fn func() (interface{}, error)) (interface{}, error) - DoEx(key string, fn func() (interface{}, error)) (interface{}, bool, error) + Do(key string, fn func() (any, error)) (any, error) + DoEx(key string, fn func() (any, error)) (any, bool, error) } call struct { wg sync.WaitGroup - val interface{} + val any err error } @@ -33,7 +33,7 @@ func NewSingleFlight() SingleFlight { } } -func (g *flightGroup) Do(key string, fn func() (interface{}, error)) (interface{}, error) { +func (g *flightGroup) Do(key string, fn func() (any, error)) (any, error) { c, done := g.createCall(key) if done { return c.val, c.err @@ -43,7 +43,7 @@ func (g *flightGroup) Do(key string, fn func() (interface{}, error)) (interface{ return c.val, c.err } -func (g *flightGroup) DoEx(key string, fn func() (interface{}, error)) (val interface{}, fresh bool, err error) { +func (g *flightGroup) DoEx(key string, fn func() (any, error)) (val any, fresh bool, err error) { c, done := g.createCall(key) if done { return c.val, false, c.err @@ -69,7 +69,7 @@ func (g *flightGroup) createCall(key string) (c *call, done bool) { return c, false } -func (g *flightGroup) makeCall(c *call, key string, fn func() (interface{}, error)) { +func (g *flightGroup) makeCall(c *call, key string, fn func() (any, error)) { defer func() { g.lock.Lock() delete(g.calls, key) diff --git a/core/syncx/singleflight_test.go b/core/syncx/singleflight_test.go index b1ffdf69..ba68f9d1 100644 --- a/core/syncx/singleflight_test.go +++ b/core/syncx/singleflight_test.go @@ -11,7 +11,7 @@ import ( func TestExclusiveCallDo(t *testing.T) { g := NewSingleFlight() - v, err := g.Do("key", func() (interface{}, error) { + v, err := g.Do("key", func() (any, error) { return "bar", nil }) if got, want := fmt.Sprintf("%v (%T)", v, v), "bar (string)"; got != want { @@ -25,7 +25,7 @@ func TestExclusiveCallDo(t *testing.T) { func TestExclusiveCallDoErr(t *testing.T) { g := NewSingleFlight() someErr := errors.New("some error") - v, err := g.Do("key", func() (interface{}, error) { + v, err := g.Do("key", func() (any, error) { return nil, someErr }) if err != someErr { @@ -40,7 +40,7 @@ func TestExclusiveCallDoDupSuppress(t *testing.T) { g := NewSingleFlight() c := make(chan string) var calls int32 - fn := func() (interface{}, error) { + fn := func() (any, error) { atomic.AddInt32(&calls, 1) return <-c, nil } @@ -79,7 +79,7 @@ func TestExclusiveCallDoDiffDupSuppress(t *testing.T) { wg.Add(1) go func(k string) { <-broadcast // get all goroutines ready - _, err := g.Do(k, func() (interface{}, error) { + _, err := g.Do(k, func() (any, error) { atomic.AddInt32(&calls, 1) time.Sleep(10 * time.Millisecond) return nil, nil @@ -105,7 +105,7 @@ func TestExclusiveCallDoExDupSuppress(t *testing.T) { g := NewSingleFlight() c := make(chan string) var calls int32 - fn := func() (interface{}, error) { + fn := func() (any, error) { atomic.AddInt32(&calls, 1) return <-c, nil } diff --git a/core/trace/message.go b/core/trace/message.go index de0c5f90..93c52c7d 100644 --- a/core/trace/message.go +++ b/core/trace/message.go @@ -21,7 +21,7 @@ type messageType attribute.KeyValue // Event adds an event of the messageType to the span associated with the // passed context with id and size (if message is a proto message). -func (m messageType) Event(ctx context.Context, id int, message interface{}) { +func (m messageType) Event(ctx context.Context, id int, message any) { span := trace.SpanFromContext(ctx) if p, ok := message.(proto.Message); ok { span.AddEvent(messageEvent, trace.WithAttributes( diff --git a/gateway/internal/requestparser.go b/gateway/internal/requestparser.go index 3f27dec0..f239c0a8 100644 --- a/gateway/internal/requestparser.go +++ b/gateway/internal/requestparser.go @@ -33,7 +33,7 @@ func NewRequestParser(r *http.Request, resolver jsonpb.AnyResolver) (grpcurl.Req return grpcurl.NewJSONRequestParser(body, resolver), nil } - m := make(map[string]interface{}) + m := make(map[string]any) if err := json.NewDecoder(body).Decode(&m); err != nil { return nil, err } @@ -45,7 +45,7 @@ func NewRequestParser(r *http.Request, resolver jsonpb.AnyResolver) (grpcurl.Req return buildJsonRequestParser(m, resolver) } -func buildJsonRequestParser(m map[string]interface{}, resolver jsonpb.AnyResolver) ( +func buildJsonRequestParser(m map[string]any, resolver jsonpb.AnyResolver) ( grpcurl.RequestParser, error) { var buf bytes.Buffer if err := json.NewEncoder(&buf).Encode(m); err != nil { diff --git a/gateway/internal/requestparser_test.go b/gateway/internal/requestparser_test.go index 715b0360..709953cd 100644 --- a/gateway/internal/requestparser_test.go +++ b/gateway/internal/requestparser_test.go @@ -88,7 +88,7 @@ func TestNewRequestParserWithBadForm(t *testing.T) { } func TestRequestParser_buildJsonRequestParser(t *testing.T) { - parser, err := buildJsonRequestParser(map[string]interface{}{"a": make(chan int)}, nil) + parser, err := buildJsonRequestParser(map[string]any{"a": make(chan int)}, nil) assert.NotNil(t, err) assert.Nil(t, parser) } diff --git a/gateway/server.go b/gateway/server.go index bd9a1f69..489796e0 100644 --- a/gateway/server.go +++ b/gateway/server.go @@ -63,11 +63,11 @@ func (s *Server) build() error { return err } - return mr.MapReduceVoid(func(source chan<- interface{}) { + return mr.MapReduceVoid(func(source chan<- any) { for _, up := range s.upstreams { source <- up } - }, func(item interface{}, writer mr.Writer, cancel func(error)) { + }, func(item any, writer mr.Writer, cancel func(error)) { up := item.(Upstream) cli := zrpc.MustNewClient(up.Grpc) source, err := s.createDescriptorSource(cli, up) @@ -109,7 +109,7 @@ func (s *Server) build() error { Handler: s.buildHandler(source, resolver, cli, m.RpcPath), }) } - }, func(pipe <-chan interface{}, cancel func(error)) { + }, func(pipe <-chan any, cancel func(error)) { for item := range pipe { route := item.(rest.Route) s.Server.AddRoute(route) diff --git a/internal/encoding/encoding.go b/internal/encoding/encoding.go index cfa754d9..af56a497 100644 --- a/internal/encoding/encoding.go +++ b/internal/encoding/encoding.go @@ -10,7 +10,7 @@ import ( ) func TomlToJson(data []byte) ([]byte, error) { - var val interface{} + var val any if err := toml.NewDecoder(bytes.NewReader(data)).Decode(&val); err != nil { return nil, err } @@ -24,7 +24,7 @@ func TomlToJson(data []byte) ([]byte, error) { } func YamlToJson(data []byte) ([]byte, error) { - var val interface{} + var val any if err := yaml.Unmarshal(data, &val); err != nil { return nil, err } @@ -39,31 +39,31 @@ func YamlToJson(data []byte) ([]byte, error) { return buf.Bytes(), nil } -func convertKeyToString(in map[interface{}]interface{}) map[string]interface{} { - res := make(map[string]interface{}) +func convertKeyToString(in map[any]any) map[string]any { + res := make(map[string]any) for k, v := range in { res[lang.Repr(k)] = toStringKeyMap(v) } return res } -func convertNumberToJsonNumber(in interface{}) json.Number { +func convertNumberToJsonNumber(in any) json.Number { return json.Number(lang.Repr(in)) } -func convertSlice(in []interface{}) []interface{} { - res := make([]interface{}, len(in)) +func convertSlice(in []any) []any { + res := make([]any, len(in)) for i, v := range in { res[i] = toStringKeyMap(v) } return res } -func toStringKeyMap(v interface{}) interface{} { +func toStringKeyMap(v any) any { switch v := v.(type) { - case []interface{}: + case []any: return convertSlice(v) - case map[interface{}]interface{}: + case map[any]any: return convertKeyToString(v) case bool, string: return v diff --git a/rest/chain/chain_test.go b/rest/chain/chain_test.go index 1aeb7895..9e1781cf 100644 --- a/rest/chain/chain_test.go +++ b/rest/chain/chain_test.go @@ -23,7 +23,7 @@ func tagMiddleware(tag string) Middleware { // Not recommended (https://golang.org/pkg/reflect/#Value.Pointer), // but the best we can do. -func funcsEqual(f1, f2 interface{}) bool { +func funcsEqual(f1, f2 any) bool { val1 := reflect.ValueOf(f1) val2 := reflect.ValueOf(f2) return val1.Pointer() == val2.Pointer() diff --git a/rest/handler/authhandler_test.go b/rest/handler/authhandler_test.go index ad56557c..27347a5c 100644 --- a/rest/handler/authhandler_test.go +++ b/rest/handler/authhandler_test.go @@ -34,7 +34,7 @@ func TestAuthHandlerFailed(t *testing.T) { func TestAuthHandler(t *testing.T) { const key = "B63F477D-BBA3-4E52-96D3-C0034C27694A" req := httptest.NewRequest(http.MethodGet, "http://localhost", http.NoBody) - token, err := buildToken(key, map[string]interface{}{ + token, err := buildToken(key, map[string]any{ "key": "value", }, 3600) assert.Nil(t, err) @@ -63,7 +63,7 @@ func TestAuthHandlerWithPrevSecret(t *testing.T) { prevKey = "B63F477D-BBA3-4E52-96D3-C0034C27694A" ) req := httptest.NewRequest(http.MethodGet, "http://localhost", http.NoBody) - token, err := buildToken(key, map[string]interface{}{ + token, err := buildToken(key, map[string]any{ "key": "value", }, 3600) assert.Nil(t, err) @@ -90,7 +90,7 @@ func TestAuthHandler_NilError(t *testing.T) { }) } -func buildToken(secretKey string, payloads map[string]interface{}, seconds int64) (string, error) { +func buildToken(secretKey string, payloads map[string]any, seconds int64) (string, error) { now := time.Now().Unix() claims := make(jwt.MapClaims) claims["exp"] = now + seconds diff --git a/rest/handler/timeouthandler.go b/rest/handler/timeouthandler.go index d234e3cb..f155c062 100644 --- a/rest/handler/timeouthandler.go +++ b/rest/handler/timeouthandler.go @@ -69,7 +69,7 @@ func (h *timeoutHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { h: make(http.Header), req: r, } - panicChan := make(chan interface{}, 1) + panicChan := make(chan any, 1) go func() { defer func() { if p := recover(); p != nil { diff --git a/rest/httpc/requests.go b/rest/httpc/requests.go index 4112337a..4b3fc60b 100644 --- a/rest/httpc/requests.go +++ b/rest/httpc/requests.go @@ -28,7 +28,7 @@ var interceptors = []internal.Interceptor{ // Do sends an HTTP request with the given arguments and returns an HTTP response. // data is automatically marshal into a *httpRequest, typically it's defined in an API file. -func Do(ctx context.Context, method, url string, data interface{}) (*http.Response, error) { +func Do(ctx context.Context, method, url string, data any) (*http.Response, error) { req, err := buildRequest(ctx, method, url, data) if err != nil { return nil, err @@ -54,7 +54,7 @@ func (c defaultClient) do(r *http.Request) (*http.Response, error) { return http.DefaultClient.Do(r) } -func buildFormQuery(u *nurl.URL, val map[string]interface{}) string { +func buildFormQuery(u *nurl.URL, val map[string]any) string { query := u.Query() for k, v := range val { query.Add(k, fmt.Sprint(v)) @@ -63,13 +63,13 @@ func buildFormQuery(u *nurl.URL, val map[string]interface{}) string { return query.Encode() } -func buildRequest(ctx context.Context, method, url string, data interface{}) (*http.Request, error) { +func buildRequest(ctx context.Context, method, url string, data any) (*http.Request, error) { u, err := nurl.Parse(url) if err != nil { return nil, err } - var val map[string]map[string]interface{} + var val map[string]map[string]any if data != nil { val, err = mapping.Marshal(data) if err != nil { @@ -111,13 +111,13 @@ func buildRequest(ctx context.Context, method, url string, data interface{}) (*h return req, nil } -func fillHeader(r *http.Request, val map[string]interface{}) { +func fillHeader(r *http.Request, val map[string]any) { for k, v := range val { r.Header.Add(k, fmt.Sprint(v)) } } -func fillPath(u *nurl.URL, val map[string]interface{}) error { +func fillPath(u *nurl.URL, val map[string]any) error { used := make(map[string]lang.PlaceholderType) fields := strings.Split(u.Path, slash) diff --git a/rest/httpc/responses.go b/rest/httpc/responses.go index 7207cdc7..8c99177f 100644 --- a/rest/httpc/responses.go +++ b/rest/httpc/responses.go @@ -12,7 +12,7 @@ import ( ) // Parse parses the response. -func Parse(resp *http.Response, val interface{}) error { +func Parse(resp *http.Response, val any) error { if err := ParseHeaders(resp, val); err != nil { return err } @@ -21,12 +21,12 @@ func Parse(resp *http.Response, val interface{}) error { } // ParseHeaders parses the response headers. -func ParseHeaders(resp *http.Response, val interface{}) error { +func ParseHeaders(resp *http.Response, val any) error { return encoding.ParseHeaders(resp.Header, val) } // ParseJsonBody parses the response body, which should be in json content type. -func ParseJsonBody(resp *http.Response, val interface{}) error { +func ParseJsonBody(resp *http.Response, val any) error { defer resp.Body.Close() if isContentTypeJson(resp) { diff --git a/rest/httpc/service.go b/rest/httpc/service.go index fc80697d..d69b69e2 100644 --- a/rest/httpc/service.go +++ b/rest/httpc/service.go @@ -14,7 +14,7 @@ type ( // Service represents a remote HTTP service. Service interface { // Do sends an HTTP request with the given arguments and returns an HTTP response. - Do(ctx context.Context, method, url string, data interface{}) (*http.Response, error) + Do(ctx context.Context, method, url string, data any) (*http.Response, error) // DoRequest sends a HTTP request to the service. DoRequest(r *http.Request) (*http.Response, error) } @@ -43,7 +43,7 @@ func NewServiceWithClient(name string, cli *http.Client, opts ...Option) Service } // Do sends an HTTP request with the given arguments and returns an HTTP response. -func (s namedService) Do(ctx context.Context, method, url string, data interface{}) (*http.Response, error) { +func (s namedService) Do(ctx context.Context, method, url string, data any) (*http.Response, error) { req, err := buildRequest(ctx, method, url, data) if err != nil { return nil, err diff --git a/rest/httpx/requests.go b/rest/httpx/requests.go index e46025b5..9dfec221 100644 --- a/rest/httpx/requests.go +++ b/rest/httpx/requests.go @@ -26,7 +26,7 @@ var ( ) // Parse parses the request. -func Parse(r *http.Request, v interface{}) error { +func Parse(r *http.Request, v any) error { if err := ParsePath(r, v); err != nil { return err } @@ -43,12 +43,12 @@ func Parse(r *http.Request, v interface{}) error { } // ParseHeaders parses the headers request. -func ParseHeaders(r *http.Request, v interface{}) error { +func ParseHeaders(r *http.Request, v any) error { return encoding.ParseHeaders(r.Header, v) } // ParseForm parses the form request. -func ParseForm(r *http.Request, v interface{}) error { +func ParseForm(r *http.Request, v any) error { params, err := GetFormValues(r) if err != nil { return err @@ -80,7 +80,7 @@ func ParseHeader(headerValue string) map[string]string { } // ParseJsonBody parses the post request which contains json in body. -func ParseJsonBody(r *http.Request, v interface{}) error { +func ParseJsonBody(r *http.Request, v any) error { if withJsonBody(r) { reader := io.LimitReader(r.Body, maxBodyLen) return mapping.UnmarshalJsonReader(reader, v) @@ -91,9 +91,9 @@ func ParseJsonBody(r *http.Request, v interface{}) error { // ParsePath parses the symbols reside in url path. // Like http://localhost/bag/:name -func ParsePath(r *http.Request, v interface{}) error { +func ParsePath(r *http.Request, v any) error { vars := pathvar.Vars(r) - m := make(map[string]interface{}, len(vars)) + m := make(map[string]any, len(vars)) for k, v := range vars { m[k] = v } diff --git a/rest/httpx/responses.go b/rest/httpx/responses.go index fa6ca808..99b17fd8 100644 --- a/rest/httpx/responses.go +++ b/rest/httpx/responses.go @@ -13,8 +13,8 @@ import ( ) var ( - errorHandler func(error) (int, interface{}) - errorHandlerCtx func(context.Context, error) (int, interface{}) + errorHandler func(error) (int, any) + errorHandlerCtx func(context.Context, error) (int, any) lock sync.RWMutex ) @@ -34,13 +34,13 @@ func ErrorCtx(ctx context.Context, w http.ResponseWriter, err error, handlerCtx := errorHandlerCtx lock.RUnlock() - var handler func(error) (int, interface{}) + var handler func(error) (int, any) if handlerCtx != nil { - handler = func(err error) (int, interface{}) { + handler = func(err error) (int, any) { return handlerCtx(ctx, err) } } - writeJson := func(w http.ResponseWriter, code int, v interface{}) { + writeJson := func(w http.ResponseWriter, code int, v any) { WriteJsonCtx(ctx, w, code, v) } doHandleError(w, err, handler, writeJson, fns...) @@ -52,45 +52,45 @@ func Ok(w http.ResponseWriter) { } // OkJson writes v into w with 200 OK. -func OkJson(w http.ResponseWriter, v interface{}) { +func OkJson(w http.ResponseWriter, v any) { WriteJson(w, http.StatusOK, v) } // OkJsonCtx writes v into w with 200 OK. -func OkJsonCtx(ctx context.Context, w http.ResponseWriter, v interface{}) { +func OkJsonCtx(ctx context.Context, w http.ResponseWriter, v any) { WriteJsonCtx(ctx, w, http.StatusOK, v) } // SetErrorHandler sets the error handler, which is called on calling Error. -func SetErrorHandler(handler func(error) (int, interface{})) { +func SetErrorHandler(handler func(error) (int, any)) { lock.Lock() defer lock.Unlock() errorHandler = handler } // SetErrorHandlerCtx sets the error handler, which is called on calling Error. -func SetErrorHandlerCtx(handlerCtx func(context.Context, error) (int, interface{})) { +func SetErrorHandlerCtx(handlerCtx func(context.Context, error) (int, any)) { lock.Lock() defer lock.Unlock() errorHandlerCtx = handlerCtx } // WriteJson writes v as json string into w with code. -func WriteJson(w http.ResponseWriter, code int, v interface{}) { +func WriteJson(w http.ResponseWriter, code int, v any) { if err := doWriteJson(w, code, v); err != nil { logx.Error(err) } } // WriteJsonCtx writes v as json string into w with code. -func WriteJsonCtx(ctx context.Context, w http.ResponseWriter, code int, v interface{}) { +func WriteJsonCtx(ctx context.Context, w http.ResponseWriter, code int, v any) { if err := doWriteJson(w, code, v); err != nil { logx.WithContext(ctx).Error(err) } } -func doHandleError(w http.ResponseWriter, err error, handler func(error) (int, interface{}), - writeJson func(w http.ResponseWriter, code int, v interface{}), +func doHandleError(w http.ResponseWriter, err error, handler func(error) (int, any), + writeJson func(w http.ResponseWriter, code int, v any), fns ...func(w http.ResponseWriter, err error)) { if handler == nil { if len(fns) > 0 { @@ -122,7 +122,7 @@ func doHandleError(w http.ResponseWriter, err error, handler func(error) (int, i } } -func doWriteJson(w http.ResponseWriter, code int, v interface{}) error { +func doWriteJson(w http.ResponseWriter, code int, v any) error { bs, err := json.Marshal(v) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) diff --git a/rest/httpx/responses_test.go b/rest/httpx/responses_test.go index aef9f390..a881dbad 100644 --- a/rest/httpx/responses_test.go +++ b/rest/httpx/responses_test.go @@ -30,7 +30,7 @@ func TestError(t *testing.T) { tests := []struct { name string input string - errorHandler func(error) (int, interface{}) + errorHandler func(error) (int, any) expectHasBody bool expectBody string expectCode int @@ -45,7 +45,7 @@ func TestError(t *testing.T) { { name: "customized error handler return string", input: body, - errorHandler: func(err error) (int, interface{}) { + errorHandler: func(err error) (int, any) { return http.StatusForbidden, err.Error() }, expectHasBody: true, @@ -55,7 +55,7 @@ func TestError(t *testing.T) { { name: "customized error handler return error", input: body, - errorHandler: func(err error) (int, interface{}) { + errorHandler: func(err error) (int, any) { return http.StatusForbidden, err }, expectHasBody: true, @@ -65,7 +65,7 @@ func TestError(t *testing.T) { { name: "customized error handler return nil", input: body, - errorHandler: func(err error) (int, interface{}) { + errorHandler: func(err error) (int, any) { return http.StatusForbidden, nil }, expectHasBody: false, @@ -174,7 +174,7 @@ func TestWriteJsonMarshalFailed(t *testing.T) { w := tracedResponseWriter{ headers: make(map[string][]string), } - WriteJson(&w, http.StatusOK, map[string]interface{}{ + WriteJson(&w, http.StatusOK, map[string]any{ "Data": complex(0, 0), }) assert.Equal(t, http.StatusInternalServerError, w.code) @@ -225,7 +225,7 @@ func TestErrorCtx(t *testing.T) { tests := []struct { name string input string - errorHandlerCtx func(context.Context, error) (int, interface{}) + errorHandlerCtx func(context.Context, error) (int, any) expectHasBody bool expectBody string expectCode int @@ -240,7 +240,7 @@ func TestErrorCtx(t *testing.T) { { name: "customized error handler return string", input: body, - errorHandlerCtx: func(ctx context.Context, err error) (int, interface{}) { + errorHandlerCtx: func(ctx context.Context, err error) (int, any) { return http.StatusForbidden, err.Error() }, expectHasBody: true, @@ -250,7 +250,7 @@ func TestErrorCtx(t *testing.T) { { name: "customized error handler return error", input: body, - errorHandlerCtx: func(ctx context.Context, err error) (int, interface{}) { + errorHandlerCtx: func(ctx context.Context, err error) (int, any) { return http.StatusForbidden, err }, expectHasBody: true, @@ -260,7 +260,7 @@ func TestErrorCtx(t *testing.T) { { name: "customized error handler return nil", input: body, - errorHandlerCtx: func(context.Context, error) (int, interface{}) { + errorHandlerCtx: func(context.Context, error) (int, any) { return http.StatusForbidden, nil }, expectHasBody: false, @@ -292,7 +292,7 @@ func TestErrorCtx(t *testing.T) { }) } - //The current handler is a global event,Set default values to avoid impacting subsequent unit tests + // The current handler is a global event,Set default values to avoid impacting subsequent unit tests SetErrorHandlerCtx(nil) } @@ -322,7 +322,7 @@ func TestWriteJsonCtxMarshalFailed(t *testing.T) { w := tracedResponseWriter{ headers: make(map[string][]string), } - WriteJsonCtx(context.Background(), &w, http.StatusOK, map[string]interface{}{ + WriteJsonCtx(context.Background(), &w, http.StatusOK, map[string]any{ "Data": complex(0, 0), }) assert.Equal(t, http.StatusInternalServerError, w.code) diff --git a/rest/httpx/util.go b/rest/httpx/util.go index 216abaa0..23419614 100644 --- a/rest/httpx/util.go +++ b/rest/httpx/util.go @@ -5,7 +5,7 @@ import "net/http" const xForwardedFor = "X-Forwarded-For" // GetFormValues returns the form values. -func GetFormValues(r *http.Request) (map[string]interface{}, error) { +func GetFormValues(r *http.Request) (map[string]any, error) { if err := r.ParseForm(); err != nil { return nil, err } @@ -16,7 +16,7 @@ func GetFormValues(r *http.Request) (map[string]interface{}, error) { } } - params := make(map[string]interface{}, len(r.Form)) + params := make(map[string]any, len(r.Form)) for name := range r.Form { formValue := r.Form.Get(name) if len(formValue) > 0 { diff --git a/rest/internal/encoding/parser.go b/rest/internal/encoding/parser.go index b9bfec05..27a4b3a7 100644 --- a/rest/internal/encoding/parser.go +++ b/rest/internal/encoding/parser.go @@ -13,8 +13,8 @@ var headerUnmarshaler = mapping.NewUnmarshaler(headerKey, mapping.WithStringValu mapping.WithCanonicalKeyFunc(textproto.CanonicalMIMEHeaderKey)) // ParseHeaders parses the headers request. -func ParseHeaders(header http.Header, v interface{}) error { - m := map[string]interface{}{} +func ParseHeaders(header http.Header, v any) error { + m := map[string]any{} for k, v := range header { if len(v) == 1 { m[k] = v[0] diff --git a/rest/internal/log.go b/rest/internal/log.go index 6f4719f0..0e921afb 100644 --- a/rest/internal/log.go +++ b/rest/internal/log.go @@ -53,22 +53,22 @@ func (lc *LogCollector) takeAll() []string { } // Error logs the given v along with r in error log. -func Error(r *http.Request, v ...interface{}) { +func Error(r *http.Request, v ...any) { logx.WithContext(r.Context()).Error(format(r, v...)) } // Errorf logs the given v with format along with r in error log. -func Errorf(r *http.Request, format string, v ...interface{}) { +func Errorf(r *http.Request, format string, v ...any) { logx.WithContext(r.Context()).Error(formatf(r, format, v...)) } // Info logs the given v along with r in access log. -func Info(r *http.Request, v ...interface{}) { +func Info(r *http.Request, v ...any) { appendLog(r, format(r, v...)) } // Infof logs the given v with format along with r in access log. -func Infof(r *http.Request, format string, v ...interface{}) { +func Infof(r *http.Request, format string, v ...any) { appendLog(r, formatf(r, format, v...)) } @@ -79,11 +79,11 @@ func appendLog(r *http.Request, message string) { } } -func format(r *http.Request, v ...interface{}) string { +func format(r *http.Request, v ...any) string { return formatWithReq(r, fmt.Sprint(v...)) } -func formatf(r *http.Request, format string, v ...interface{}) string { +func formatf(r *http.Request, format string, v ...any) string { return formatWithReq(r, fmt.Sprintf(format, v...)) } diff --git a/rest/token/tokenparser.go b/rest/token/tokenparser.go index 2e1ef68c..775ef49a 100644 --- a/rest/token/tokenparser.go +++ b/rest/token/tokenparser.go @@ -80,7 +80,7 @@ func (tp *TokenParser) ParseToken(r *http.Request, secret, prevSecret string) (* func (tp *TokenParser) doParseToken(r *http.Request, secret string) (*jwt.Token, error) { return request.ParseFromRequest(r, request.AuthorizationHeaderExtractor, - func(token *jwt.Token) (interface{}, error) { + func(token *jwt.Token) (any, error) { return []byte(secret), nil }, request.WithParser(newParser())) } @@ -88,7 +88,7 @@ func (tp *TokenParser) doParseToken(r *http.Request, secret string) (*jwt.Token, func (tp *TokenParser) incrementCount(secret string) { now := timex.Now() if tp.resetTime+tp.resetDuration < now { - tp.history.Range(func(key, value interface{}) bool { + tp.history.Range(func(key, value any) bool { tp.history.Delete(key) return true }) diff --git a/rest/token/tokenparser_test.go b/rest/token/tokenparser_test.go index 00d0ee61..147d6438 100644 --- a/rest/token/tokenparser_test.go +++ b/rest/token/tokenparser_test.go @@ -32,7 +32,7 @@ func TestTokenParser(t *testing.T) { for _, pair := range keys { req := httptest.NewRequest(http.MethodGet, "http://localhost", http.NoBody) - token, err := buildToken(key, map[string]interface{}{ + token, err := buildToken(key, map[string]any{ "key": "value", }, 3600) assert.Nil(t, err) @@ -51,7 +51,7 @@ func TestTokenParser_Expired(t *testing.T) { prevKey = "B63F477D-BBA3-4E52-96D3-C0034C27694A" ) req := httptest.NewRequest(http.MethodGet, "http://localhost", http.NoBody) - token, err := buildToken(key, map[string]interface{}{ + token, err := buildToken(key, map[string]any{ "key": "value", }, 3600) assert.Nil(t, err) @@ -70,7 +70,7 @@ func TestTokenParser_Expired(t *testing.T) { assert.Equal(t, "value", tok.Claims.(jwt.MapClaims)["key"]) } -func buildToken(secretKey string, payloads map[string]interface{}, seconds int64) (string, error) { +func buildToken(secretKey string, payloads map[string]any, seconds int64) (string, error) { now := time.Now().Unix() claims := make(jwt.MapClaims) claims["exp"] = now + seconds diff --git a/tools/goctl/api/gogen/genroutes.go b/tools/goctl/api/gogen/genroutes.go index c6272dc3..d2cf14d9 100644 --- a/tools/goctl/api/gogen/genroutes.go +++ b/tools/goctl/api/gogen/genroutes.go @@ -174,7 +174,7 @@ rest.WithPrefix("%s"),`, g.prefix) category: category, templateFile: routesTemplateFile, builtinTemplate: routesTemplate, - data: map[string]interface{}{ + data: map[string]any{ "hasTimeout": hasTimeout, "importPackages": genRouteImports(rootPkg, api), "routesAdditions": strings.TrimSpace(builder.String()), diff --git a/tools/goctl/api/gogen/gentypes.go b/tools/goctl/api/gogen/gentypes.go index 9e91735f..36e3fe92 100644 --- a/tools/goctl/api/gogen/gentypes.go +++ b/tools/goctl/api/gogen/gentypes.go @@ -61,7 +61,7 @@ func genTypes(dir string, cfg *config.Config, api *spec.ApiSpec) error { category: category, templateFile: typesTemplateFile, builtinTemplate: typesTemplate, - data: map[string]interface{}{ + data: map[string]any{ "types": val, "containsTime": false, }, diff --git a/tools/goctl/api/gogen/util.go b/tools/goctl/api/gogen/util.go index a8798ebd..948b1ee9 100644 --- a/tools/goctl/api/gogen/util.go +++ b/tools/goctl/api/gogen/util.go @@ -22,7 +22,7 @@ type fileGenConfig struct { category string templateFile string builtinTemplate string - data interface{} + data any } func genFile(c fileGenConfig) error { diff --git a/tools/goctl/api/javagen/gencomponents.go b/tools/goctl/api/javagen/gencomponents.go index a9c5a0e1..c8463d41 100644 --- a/tools/goctl/api/javagen/gencomponents.go +++ b/tools/goctl/api/javagen/gencomponents.go @@ -121,7 +121,7 @@ func (c *componentsContext) createComponent(dir, packetName string, ty spec.Type buffer := new(bytes.Buffer) t := template.Must(template.New("componentType").Parse(componentTemplate)) - err = t.Execute(buffer, map[string]interface{}{ + err = t.Execute(buffer, map[string]any{ "properties": propertiesString, "params": params, "constructorSetter": constructorSetter, diff --git a/tools/goctl/api/javagen/genpacket.go b/tools/goctl/api/javagen/genpacket.go index b27d5710..985ff7e6 100644 --- a/tools/goctl/api/javagen/genpacket.go +++ b/tools/goctl/api/javagen/genpacket.go @@ -65,7 +65,7 @@ func createWith(dir string, api *spec.ApiSpec, route spec.Route, packetName stri t := template.Must(template.New("packetTemplate").Parse(packetTemplate)) var tmplBytes bytes.Buffer - err = t.Execute(&tmplBytes, map[string]interface{}{ + err = t.Execute(&tmplBytes, map[string]any{ "packetName": packet, "method": strings.ToUpper(route.Method), "uri": processUri(route), diff --git a/tools/goctl/api/parser/g4/ast/api.go b/tools/goctl/api/parser/g4/ast/api.go index d90b27d5..2a757ef9 100644 --- a/tools/goctl/api/parser/g4/ast/api.go +++ b/tools/goctl/api/parser/g4/ast/api.go @@ -29,7 +29,7 @@ type Api struct { } // VisitApi implements from api.BaseApiParserVisitor -func (v *ApiVisitor) VisitApi(ctx *api.ApiContext) interface{} { +func (v *ApiVisitor) VisitApi(ctx *api.ApiContext) any { var final Api final.importM = map[string]PlaceHolder{} final.typeM = map[string]PlaceHolder{} @@ -176,7 +176,7 @@ func (v *ApiVisitor) acceptSyntax(root, final *Api) { } // VisitSpec implements from api.BaseApiParserVisitor -func (v *ApiVisitor) VisitSpec(ctx *api.SpecContext) interface{} { +func (v *ApiVisitor) VisitSpec(ctx *api.SpecContext) any { var root Api if ctx.SyntaxLit() != nil { root.Syntax = ctx.SyntaxLit().Accept(v).(*SyntaxExpr) @@ -209,7 +209,7 @@ func (a *Api) Format() error { } // Equal compares whether the element literals in two Api are equal -func (a *Api) Equal(v interface{}) bool { +func (a *Api) Equal(v any) bool { if v == nil || a == nil { return false } diff --git a/tools/goctl/api/parser/g4/ast/apiparser.go b/tools/goctl/api/parser/g4/ast/apiparser.go index 2b2c1665..4b416976 100644 --- a/tools/goctl/api/parser/g4/ast/apiparser.go +++ b/tools/goctl/api/parser/g4/ast/apiparser.go @@ -51,7 +51,7 @@ func NewParser(options ...ParserOption) *Parser { // Accept can parse any terminalNode of api tree by fn. // -- for debug -func (p *Parser) Accept(fn func(p *api.ApiParserParser, visitor *ApiVisitor) interface{}, content string) (v interface{}, err error) { +func (p *Parser) Accept(fn func(p *api.ApiParserParser, visitor *ApiVisitor) any, content string) (v any, err error) { defer func() { p := recover() if p != nil { @@ -507,7 +507,7 @@ func (p *Parser) readContent(filename string) (string, error) { } // SyntaxError accepts errors and panic it -func (p *Parser) SyntaxError(_ antlr.Recognizer, _ interface{}, line, column int, msg string, _ antlr.RecognitionException) { +func (p *Parser) SyntaxError(_ antlr.Recognizer, _ any, line, column int, msg string, _ antlr.RecognitionException) { str := fmt.Sprintf(`%s line %d:%d %s`, p.linePrefix, line, column, msg) if p.debug { p.log.Error(str) diff --git a/tools/goctl/api/parser/g4/ast/ast.go b/tools/goctl/api/parser/g4/ast/ast.go index 6d31fbf0..63a4f6aa 100644 --- a/tools/goctl/api/parser/g4/ast/ast.go +++ b/tools/goctl/api/parser/g4/ast/ast.go @@ -36,7 +36,7 @@ type ( Doc() []Expr Comment() Expr Format() error - Equal(v interface{}) bool + Equal(v any) bool } // Expr describes ast expression diff --git a/tools/goctl/api/parser/g4/ast/import.go b/tools/goctl/api/parser/g4/ast/import.go index d10c0c2e..374e16fb 100644 --- a/tools/goctl/api/parser/g4/ast/import.go +++ b/tools/goctl/api/parser/g4/ast/import.go @@ -13,7 +13,7 @@ type ImportExpr struct { } // VisitImportSpec implements from api.BaseApiParserVisitor -func (v *ApiVisitor) VisitImportSpec(ctx *api.ImportSpecContext) interface{} { +func (v *ApiVisitor) VisitImportSpec(ctx *api.ImportSpecContext) any { var list []*ImportExpr if ctx.ImportLit() != nil { lits := ctx.ImportLit().Accept(v).([]*ImportExpr) @@ -28,7 +28,7 @@ func (v *ApiVisitor) VisitImportSpec(ctx *api.ImportSpecContext) interface{} { } // VisitImportLit implements from api.BaseApiParserVisitor -func (v *ApiVisitor) VisitImportLit(ctx *api.ImportLitContext) interface{} { +func (v *ApiVisitor) VisitImportLit(ctx *api.ImportLitContext) any { importToken := v.newExprWithToken(ctx.GetImportToken()) valueExpr := ctx.ImportValue().Accept(v).(Expr) return []*ImportExpr{ @@ -42,7 +42,7 @@ func (v *ApiVisitor) VisitImportLit(ctx *api.ImportLitContext) interface{} { } // VisitImportBlock implements from api.BaseApiParserVisitor -func (v *ApiVisitor) VisitImportBlock(ctx *api.ImportBlockContext) interface{} { +func (v *ApiVisitor) VisitImportBlock(ctx *api.ImportBlockContext) any { importToken := v.newExprWithToken(ctx.GetImportToken()) values := ctx.AllImportBlockValue() var list []*ImportExpr @@ -57,7 +57,7 @@ func (v *ApiVisitor) VisitImportBlock(ctx *api.ImportBlockContext) interface{} { } // VisitImportBlockValue implements from api.BaseApiParserVisitor -func (v *ApiVisitor) VisitImportBlockValue(ctx *api.ImportBlockValueContext) interface{} { +func (v *ApiVisitor) VisitImportBlockValue(ctx *api.ImportBlockValueContext) any { value := ctx.ImportValue().Accept(v).(Expr) return &ImportExpr{ Value: value, @@ -67,7 +67,7 @@ func (v *ApiVisitor) VisitImportBlockValue(ctx *api.ImportBlockValueContext) int } // VisitImportValue implements from api.BaseApiParserVisitor -func (v *ApiVisitor) VisitImportValue(ctx *api.ImportValueContext) interface{} { +func (v *ApiVisitor) VisitImportValue(ctx *api.ImportValueContext) any { return v.newExprWithTerminalNode(ctx.STRING()) } @@ -78,7 +78,7 @@ func (i *ImportExpr) Format() error { } // Equal compares whether the element literals in two ImportExpr are equal -func (i *ImportExpr) Equal(v interface{}) bool { +func (i *ImportExpr) Equal(v any) bool { if v == nil { return false } diff --git a/tools/goctl/api/parser/g4/ast/info.go b/tools/goctl/api/parser/g4/ast/info.go index 0b56d940..b086fb9e 100644 --- a/tools/goctl/api/parser/g4/ast/info.go +++ b/tools/goctl/api/parser/g4/ast/info.go @@ -13,7 +13,7 @@ type InfoExpr struct { } // VisitInfoSpec implements from api.BaseApiParserVisitor -func (v *ApiVisitor) VisitInfoSpec(ctx *api.InfoSpecContext) interface{} { +func (v *ApiVisitor) VisitInfoSpec(ctx *api.InfoSpecContext) any { var expr InfoExpr expr.Info = v.newExprWithToken(ctx.GetInfoToken()) expr.Lp = v.newExprWithToken(ctx.GetLp()) @@ -38,7 +38,7 @@ func (i *InfoExpr) Format() error { } // Equal compares whether the element literals in two InfoExpr are equal -func (i *InfoExpr) Equal(v interface{}) bool { +func (i *InfoExpr) Equal(v any) bool { if v == nil { return false } diff --git a/tools/goctl/api/parser/g4/ast/kv.go b/tools/goctl/api/parser/g4/ast/kv.go index 9bf6976b..0addde6c 100644 --- a/tools/goctl/api/parser/g4/ast/kv.go +++ b/tools/goctl/api/parser/g4/ast/kv.go @@ -15,7 +15,7 @@ type KvExpr struct { } // VisitKvLit implements from api.BaseApiParserVisitor -func (v *ApiVisitor) VisitKvLit(ctx *api.KvLitContext) interface{} { +func (v *ApiVisitor) VisitKvLit(ctx *api.KvLitContext) any { var kvExpr KvExpr kvExpr.Key = v.newExprWithToken(ctx.GetKey()) commentExpr := v.getComment(ctx) @@ -57,7 +57,7 @@ func (k *KvExpr) Format() error { } // Equal compares whether the element literals in two KvExpr are equal -func (k *KvExpr) Equal(v interface{}) bool { +func (k *KvExpr) Equal(v any) bool { if v == nil { return false } diff --git a/tools/goctl/api/parser/g4/ast/service.go b/tools/goctl/api/parser/g4/ast/service.go index debef376..1bd70865 100644 --- a/tools/goctl/api/parser/g4/ast/service.go +++ b/tools/goctl/api/parser/g4/ast/service.go @@ -78,7 +78,7 @@ type Body struct { } // VisitServiceSpec implements from api.BaseApiParserVisitor -func (v *ApiVisitor) VisitServiceSpec(ctx *api.ServiceSpecContext) interface{} { +func (v *ApiVisitor) VisitServiceSpec(ctx *api.ServiceSpecContext) any { var serviceSpec Service if ctx.AtServer() != nil { serviceSpec.AtServer = ctx.AtServer().Accept(v).(*AtServer) @@ -89,7 +89,7 @@ func (v *ApiVisitor) VisitServiceSpec(ctx *api.ServiceSpecContext) interface{} { } // VisitAtServer implements from api.BaseApiParserVisitor -func (v *ApiVisitor) VisitAtServer(ctx *api.AtServerContext) interface{} { +func (v *ApiVisitor) VisitAtServer(ctx *api.AtServerContext) any { var atServer AtServer atServer.AtServerToken = v.newExprWithTerminalNode(ctx.ATSERVER()) atServer.Lp = v.newExprWithToken(ctx.GetLp()) @@ -103,7 +103,7 @@ func (v *ApiVisitor) VisitAtServer(ctx *api.AtServerContext) interface{} { } // VisitServiceApi implements from api.BaseApiParserVisitor -func (v *ApiVisitor) VisitServiceApi(ctx *api.ServiceApiContext) interface{} { +func (v *ApiVisitor) VisitServiceApi(ctx *api.ServiceApiContext) any { var serviceApi ServiceApi serviceApi.ServiceToken = v.newExprWithToken(ctx.GetServiceToken()) serviceName := ctx.ServiceName() @@ -119,7 +119,7 @@ func (v *ApiVisitor) VisitServiceApi(ctx *api.ServiceApiContext) interface{} { } // VisitServiceRoute implements from api.BaseApiParserVisitor -func (v *ApiVisitor) VisitServiceRoute(ctx *api.ServiceRouteContext) interface{} { +func (v *ApiVisitor) VisitServiceRoute(ctx *api.ServiceRouteContext) any { var serviceRoute ServiceRoute if ctx.AtDoc() != nil { serviceRoute.AtDoc = ctx.AtDoc().Accept(v).(*AtDoc) @@ -136,7 +136,7 @@ func (v *ApiVisitor) VisitServiceRoute(ctx *api.ServiceRouteContext) interface{} } // VisitAtDoc implements from api.BaseApiParserVisitor -func (v *ApiVisitor) VisitAtDoc(ctx *api.AtDocContext) interface{} { +func (v *ApiVisitor) VisitAtDoc(ctx *api.AtDocContext) any { var atDoc AtDoc atDoc.AtDocToken = v.newExprWithTerminalNode(ctx.ATDOC()) @@ -166,7 +166,7 @@ func (v *ApiVisitor) VisitAtDoc(ctx *api.AtDocContext) interface{} { } // VisitAtHandler implements from api.BaseApiParserVisitor -func (v *ApiVisitor) VisitAtHandler(ctx *api.AtHandlerContext) interface{} { +func (v *ApiVisitor) VisitAtHandler(ctx *api.AtHandlerContext) any { var atHandler AtHandler astHandlerExpr := v.newExprWithTerminalNode(ctx.ATHANDLER()) atHandler.AtHandlerToken = astHandlerExpr @@ -177,7 +177,7 @@ func (v *ApiVisitor) VisitAtHandler(ctx *api.AtHandlerContext) interface{} { } // serVisitRoute implements from api.BaseApiParserVisitor -func (v *ApiVisitor) VisitRoute(ctx *api.RouteContext) interface{} { +func (v *ApiVisitor) VisitRoute(ctx *api.RouteContext) any { var route Route path := ctx.Path() methodExpr := v.newExprWithToken(ctx.GetHttpMethod()) @@ -207,7 +207,7 @@ func (v *ApiVisitor) VisitRoute(ctx *api.RouteContext) interface{} { } // VisitBody implements from api.BaseApiParserVisitor -func (v *ApiVisitor) VisitBody(ctx *api.BodyContext) interface{} { +func (v *ApiVisitor) VisitBody(ctx *api.BodyContext) any { if ctx.ID() == nil { if v.debug { msg := fmt.Sprintf( @@ -233,7 +233,7 @@ func (v *ApiVisitor) VisitBody(ctx *api.BodyContext) interface{} { } // VisitReplybody implements from api.BaseApiParserVisitor -func (v *ApiVisitor) VisitReplybody(ctx *api.ReplybodyContext) interface{} { +func (v *ApiVisitor) VisitReplybody(ctx *api.ReplybodyContext) any { if ctx.DataType() == nil { if v.debug { msg := fmt.Sprintf( @@ -294,7 +294,7 @@ func (b *Body) Format() error { } // Equal compares whether the element literals in two Body are equal -func (b *Body) Equal(v interface{}) bool { +func (b *Body) Equal(v any) bool { if v == nil { return false } @@ -332,7 +332,7 @@ func (r *Route) Comment() Expr { } // Equal compares whether the element literals in two Route are equal -func (r *Route) Equal(v interface{}) bool { +func (r *Route) Equal(v any) bool { if v == nil { return false } @@ -388,7 +388,7 @@ func (a *AtHandler) Format() error { } // Equal compares whether the element literals in two AtHandler are equal -func (a *AtHandler) Equal(v interface{}) bool { +func (a *AtHandler) Equal(v any) bool { if v == nil { return false } @@ -416,7 +416,7 @@ func (a *AtDoc) Format() error { } // Equal compares whether the element literals in two AtDoc are equal -func (a *AtDoc) Equal(v interface{}) bool { +func (a *AtDoc) Equal(v any) bool { if v == nil { return false } @@ -473,7 +473,7 @@ func (a *AtServer) Format() error { } // Equal compares whether the element literals in two AtServer are equal -func (a *AtServer) Equal(v interface{}) bool { +func (a *AtServer) Equal(v any) bool { if v == nil { return false } @@ -521,7 +521,7 @@ func (a *AtServer) Equal(v interface{}) bool { } // Equal compares whether the element literals in two ServiceRoute are equal -func (s *ServiceRoute) Equal(v interface{}) bool { +func (s *ServiceRoute) Equal(v any) bool { if v == nil { return false } @@ -572,7 +572,7 @@ func (a *ServiceApi) Format() error { } // Equal compares whether the element literals in two ServiceApi are equal -func (a *ServiceApi) Equal(v interface{}) bool { +func (a *ServiceApi) Equal(v any) bool { if v == nil { return false } @@ -630,7 +630,7 @@ func (s *Service) Format() error { } // Equal compares whether the element literals in two Service are equal -func (s *Service) Equal(v interface{}) bool { +func (s *Service) Equal(v any) bool { if v == nil { return false } diff --git a/tools/goctl/api/parser/g4/ast/syntax.go b/tools/goctl/api/parser/g4/ast/syntax.go index 0ca360f6..a543a784 100644 --- a/tools/goctl/api/parser/g4/ast/syntax.go +++ b/tools/goctl/api/parser/g4/ast/syntax.go @@ -14,7 +14,7 @@ type SyntaxExpr struct { } // VisitSyntaxLit implements from api.BaseApiParserVisitor -func (v *ApiVisitor) VisitSyntaxLit(ctx *api.SyntaxLitContext) interface{} { +func (v *ApiVisitor) VisitSyntaxLit(ctx *api.SyntaxLitContext) any { syntax := v.newExprWithToken(ctx.GetSyntaxToken()) assign := v.newExprWithToken(ctx.GetAssign()) version := v.newExprWithToken(ctx.GetVersion()) @@ -34,7 +34,7 @@ func (s *SyntaxExpr) Format() error { } // Equal compares whether the element literals in two SyntaxExpr are equal -func (s *SyntaxExpr) Equal(v interface{}) bool { +func (s *SyntaxExpr) Equal(v any) bool { if v == nil { return false } diff --git a/tools/goctl/api/parser/g4/ast/type.go b/tools/goctl/api/parser/g4/ast/type.go index 91b66d3c..43023176 100644 --- a/tools/goctl/api/parser/g4/ast/type.go +++ b/tools/goctl/api/parser/g4/ast/type.go @@ -12,7 +12,7 @@ type ( TypeExpr interface { Doc() []Expr Format() error - Equal(v interface{}) bool + Equal(v any) bool NameExpr() Expr } @@ -98,7 +98,7 @@ type ( ) // VisitTypeSpec implements from api.BaseApiParserVisitor -func (v *ApiVisitor) VisitTypeSpec(ctx *api.TypeSpecContext) interface{} { +func (v *ApiVisitor) VisitTypeSpec(ctx *api.TypeSpecContext) any { if ctx.TypeLit() != nil { return []TypeExpr{ctx.TypeLit().Accept(v).(TypeExpr)} } @@ -106,7 +106,7 @@ func (v *ApiVisitor) VisitTypeSpec(ctx *api.TypeSpecContext) interface{} { } // VisitTypeLit implements from api.BaseApiParserVisitor -func (v *ApiVisitor) VisitTypeLit(ctx *api.TypeLitContext) interface{} { +func (v *ApiVisitor) VisitTypeLit(ctx *api.TypeLitContext) any { typeLit := ctx.TypeLitBody().Accept(v) alias, ok := typeLit.(*TypeAlias) if ok { @@ -124,7 +124,7 @@ func (v *ApiVisitor) VisitTypeLit(ctx *api.TypeLitContext) interface{} { } // VisitTypeBlock implements from api.BaseApiParserVisitor -func (v *ApiVisitor) VisitTypeBlock(ctx *api.TypeBlockContext) interface{} { +func (v *ApiVisitor) VisitTypeBlock(ctx *api.TypeBlockContext) any { list := ctx.AllTypeBlockBody() var types []TypeExpr for _, each := range list { @@ -134,7 +134,7 @@ func (v *ApiVisitor) VisitTypeBlock(ctx *api.TypeBlockContext) interface{} { } // VisitTypeLitBody implements from api.BaseApiParserVisitor -func (v *ApiVisitor) VisitTypeLitBody(ctx *api.TypeLitBodyContext) interface{} { +func (v *ApiVisitor) VisitTypeLitBody(ctx *api.TypeLitBodyContext) any { if ctx.TypeAlias() != nil { return ctx.TypeAlias().Accept(v) } @@ -142,7 +142,7 @@ func (v *ApiVisitor) VisitTypeLitBody(ctx *api.TypeLitBodyContext) interface{} { } // VisitTypeBlockBody implements from api.BaseApiParserVisitor -func (v *ApiVisitor) VisitTypeBlockBody(ctx *api.TypeBlockBodyContext) interface{} { +func (v *ApiVisitor) VisitTypeBlockBody(ctx *api.TypeBlockBodyContext) any { if ctx.TypeBlockAlias() != nil { return ctx.TypeBlockAlias().Accept(v).(*TypeAlias) } @@ -150,7 +150,7 @@ func (v *ApiVisitor) VisitTypeBlockBody(ctx *api.TypeBlockBodyContext) interface } // VisitTypeStruct implements from api.BaseApiParserVisitor -func (v *ApiVisitor) VisitTypeStruct(ctx *api.TypeStructContext) interface{} { +func (v *ApiVisitor) VisitTypeStruct(ctx *api.TypeStructContext) any { var st TypeStruct st.Name = v.newExprWithToken(ctx.GetStructName()) @@ -182,7 +182,7 @@ func (v *ApiVisitor) VisitTypeStruct(ctx *api.TypeStructContext) interface{} { } // VisitTypeBlockStruct implements from api.BaseApiParserVisitor -func (v *ApiVisitor) VisitTypeBlockStruct(ctx *api.TypeBlockStructContext) interface{} { +func (v *ApiVisitor) VisitTypeBlockStruct(ctx *api.TypeBlockStructContext) any { var st TypeStruct st.Name = v.newExprWithToken(ctx.GetStructName()) @@ -214,7 +214,7 @@ func (v *ApiVisitor) VisitTypeBlockStruct(ctx *api.TypeBlockStructContext) inter } // VisitTypeBlockAlias implements from api.BaseApiParserVisitor -func (v *ApiVisitor) VisitTypeBlockAlias(ctx *api.TypeBlockAliasContext) interface{} { +func (v *ApiVisitor) VisitTypeBlockAlias(ctx *api.TypeBlockAliasContext) any { var alias TypeAlias alias.Name = v.newExprWithToken(ctx.GetAlias()) alias.Assign = v.newExprWithToken(ctx.GetAssign()) @@ -227,7 +227,7 @@ func (v *ApiVisitor) VisitTypeBlockAlias(ctx *api.TypeBlockAliasContext) interfa } // VisitTypeAlias implements from api.BaseApiParserVisitor -func (v *ApiVisitor) VisitTypeAlias(ctx *api.TypeAliasContext) interface{} { +func (v *ApiVisitor) VisitTypeAlias(ctx *api.TypeAliasContext) any { var alias TypeAlias alias.Name = v.newExprWithToken(ctx.GetAlias()) alias.Assign = v.newExprWithToken(ctx.GetAssign()) @@ -240,7 +240,7 @@ func (v *ApiVisitor) VisitTypeAlias(ctx *api.TypeAliasContext) interface{} { } // VisitField implements from api.BaseApiParserVisitor -func (v *ApiVisitor) VisitField(ctx *api.FieldContext) interface{} { +func (v *ApiVisitor) VisitField(ctx *api.FieldContext) any { iAnonymousFiled := ctx.AnonymousFiled() iNormalFieldContext := ctx.NormalField() if iAnonymousFiled != nil { @@ -253,7 +253,7 @@ func (v *ApiVisitor) VisitField(ctx *api.FieldContext) interface{} { } // VisitNormalField implements from api.BaseApiParserVisitor -func (v *ApiVisitor) VisitNormalField(ctx *api.NormalFieldContext) interface{} { +func (v *ApiVisitor) VisitNormalField(ctx *api.NormalFieldContext) any { var field TypeField field.Name = v.newExprWithToken(ctx.GetFieldName()) @@ -276,7 +276,7 @@ func (v *ApiVisitor) VisitNormalField(ctx *api.NormalFieldContext) interface{} { } // VisitAnonymousFiled implements from api.BaseApiParserVisitor -func (v *ApiVisitor) VisitAnonymousFiled(ctx *api.AnonymousFiledContext) interface{} { +func (v *ApiVisitor) VisitAnonymousFiled(ctx *api.AnonymousFiledContext) any { start := ctx.GetStart() stop := ctx.GetStop() var field TypeField @@ -298,7 +298,7 @@ func (v *ApiVisitor) VisitAnonymousFiled(ctx *api.AnonymousFiledContext) interfa } // VisitDataType implements from api.BaseApiParserVisitor -func (v *ApiVisitor) VisitDataType(ctx *api.DataTypeContext) interface{} { +func (v *ApiVisitor) VisitDataType(ctx *api.DataTypeContext) any { if ctx.ID() != nil { idExpr := v.newExprWithTerminalNode(ctx.ID()) return &Literal{Literal: idExpr} @@ -326,7 +326,7 @@ func (v *ApiVisitor) VisitDataType(ctx *api.DataTypeContext) interface{} { } // VisitPointerType implements from api.BaseApiParserVisitor -func (v *ApiVisitor) VisitPointerType(ctx *api.PointerTypeContext) interface{} { +func (v *ApiVisitor) VisitPointerType(ctx *api.PointerTypeContext) any { nameExpr := v.newExprWithTerminalNode(ctx.ID()) return &Pointer{ PointerExpr: v.newExprWithText(ctx.GetText(), ctx.GetStar().GetLine(), ctx.GetStar().GetColumn(), ctx.GetStar().GetStart(), ctx.ID().GetSymbol().GetStop()), @@ -336,7 +336,7 @@ func (v *ApiVisitor) VisitPointerType(ctx *api.PointerTypeContext) interface{} { } // VisitMapType implements from api.BaseApiParserVisitor -func (v *ApiVisitor) VisitMapType(ctx *api.MapTypeContext) interface{} { +func (v *ApiVisitor) VisitMapType(ctx *api.MapTypeContext) any { return &Map{ MapExpr: v.newExprWithText(ctx.GetText(), ctx.GetMapToken().GetLine(), ctx.GetMapToken().GetColumn(), ctx.GetMapToken().GetStart(), ctx.GetValue().GetStop().GetStop()), @@ -349,7 +349,7 @@ func (v *ApiVisitor) VisitMapType(ctx *api.MapTypeContext) interface{} { } // VisitArrayType implements from api.BaseApiParserVisitor -func (v *ApiVisitor) VisitArrayType(ctx *api.ArrayTypeContext) interface{} { +func (v *ApiVisitor) VisitArrayType(ctx *api.ArrayTypeContext) any { return &Array{ ArrayExpr: v.newExprWithText(ctx.GetText(), ctx.GetLbrack().GetLine(), ctx.GetLbrack().GetColumn(), ctx.GetLbrack().GetStart(), ctx.DataType().GetStop().GetStop()), LBrack: v.newExprWithToken(ctx.GetLbrack()), @@ -379,7 +379,7 @@ func (a *TypeAlias) Format() error { } // Equal compares whether the element literals in two TypeAlias are equal -func (a *TypeAlias) Equal(v interface{}) bool { +func (a *TypeAlias) Equal(v any) bool { if v == nil { return false } @@ -609,7 +609,7 @@ func (s *TypeStruct) NameExpr() Expr { } // Equal compares whether the element literals in two TypeStruct are equal -func (s *TypeStruct) Equal(dt interface{}) bool { +func (s *TypeStruct) Equal(dt any) bool { if dt == nil { return false } @@ -681,7 +681,7 @@ func (s *TypeStruct) Format() error { } // Equal compares whether the element literals in two TypeField are equal -func (t *TypeField) Equal(v interface{}) bool { +func (t *TypeField) Equal(v any) bool { if v == nil { return false } diff --git a/tools/goctl/api/parser/g4/gen/api/apiparser_base_visitor.go b/tools/goctl/api/parser/g4/gen/api/apiparser_base_visitor.go index 80cc07d1..00f98edd 100644 --- a/tools/goctl/api/parser/g4/gen/api/apiparser_base_visitor.go +++ b/tools/goctl/api/parser/g4/gen/api/apiparser_base_visitor.go @@ -5,154 +5,154 @@ type BaseApiParserVisitor struct { *antlr.BaseParseTreeVisitor } -func (v *BaseApiParserVisitor) VisitApi(ctx *ApiContext) interface{} { +func (v *BaseApiParserVisitor) VisitApi(ctx *ApiContext) any { return v.VisitChildren(ctx) } -func (v *BaseApiParserVisitor) VisitSpec(ctx *SpecContext) interface{} { +func (v *BaseApiParserVisitor) VisitSpec(ctx *SpecContext) any { return v.VisitChildren(ctx) } -func (v *BaseApiParserVisitor) VisitSyntaxLit(ctx *SyntaxLitContext) interface{} { +func (v *BaseApiParserVisitor) VisitSyntaxLit(ctx *SyntaxLitContext) any { return v.VisitChildren(ctx) } -func (v *BaseApiParserVisitor) VisitImportSpec(ctx *ImportSpecContext) interface{} { +func (v *BaseApiParserVisitor) VisitImportSpec(ctx *ImportSpecContext) any { return v.VisitChildren(ctx) } -func (v *BaseApiParserVisitor) VisitImportLit(ctx *ImportLitContext) interface{} { +func (v *BaseApiParserVisitor) VisitImportLit(ctx *ImportLitContext) any { return v.VisitChildren(ctx) } -func (v *BaseApiParserVisitor) VisitImportBlock(ctx *ImportBlockContext) interface{} { +func (v *BaseApiParserVisitor) VisitImportBlock(ctx *ImportBlockContext) any { return v.VisitChildren(ctx) } -func (v *BaseApiParserVisitor) VisitImportBlockValue(ctx *ImportBlockValueContext) interface{} { +func (v *BaseApiParserVisitor) VisitImportBlockValue(ctx *ImportBlockValueContext) any { return v.VisitChildren(ctx) } -func (v *BaseApiParserVisitor) VisitImportValue(ctx *ImportValueContext) interface{} { +func (v *BaseApiParserVisitor) VisitImportValue(ctx *ImportValueContext) any { return v.VisitChildren(ctx) } -func (v *BaseApiParserVisitor) VisitInfoSpec(ctx *InfoSpecContext) interface{} { +func (v *BaseApiParserVisitor) VisitInfoSpec(ctx *InfoSpecContext) any { return v.VisitChildren(ctx) } -func (v *BaseApiParserVisitor) VisitTypeSpec(ctx *TypeSpecContext) interface{} { +func (v *BaseApiParserVisitor) VisitTypeSpec(ctx *TypeSpecContext) any { return v.VisitChildren(ctx) } -func (v *BaseApiParserVisitor) VisitTypeLit(ctx *TypeLitContext) interface{} { +func (v *BaseApiParserVisitor) VisitTypeLit(ctx *TypeLitContext) any { return v.VisitChildren(ctx) } -func (v *BaseApiParserVisitor) VisitTypeBlock(ctx *TypeBlockContext) interface{} { +func (v *BaseApiParserVisitor) VisitTypeBlock(ctx *TypeBlockContext) any { return v.VisitChildren(ctx) } -func (v *BaseApiParserVisitor) VisitTypeLitBody(ctx *TypeLitBodyContext) interface{} { +func (v *BaseApiParserVisitor) VisitTypeLitBody(ctx *TypeLitBodyContext) any { return v.VisitChildren(ctx) } -func (v *BaseApiParserVisitor) VisitTypeBlockBody(ctx *TypeBlockBodyContext) interface{} { +func (v *BaseApiParserVisitor) VisitTypeBlockBody(ctx *TypeBlockBodyContext) any { return v.VisitChildren(ctx) } -func (v *BaseApiParserVisitor) VisitTypeStruct(ctx *TypeStructContext) interface{} { +func (v *BaseApiParserVisitor) VisitTypeStruct(ctx *TypeStructContext) any { return v.VisitChildren(ctx) } -func (v *BaseApiParserVisitor) VisitTypeAlias(ctx *TypeAliasContext) interface{} { +func (v *BaseApiParserVisitor) VisitTypeAlias(ctx *TypeAliasContext) any { return v.VisitChildren(ctx) } -func (v *BaseApiParserVisitor) VisitTypeBlockStruct(ctx *TypeBlockStructContext) interface{} { +func (v *BaseApiParserVisitor) VisitTypeBlockStruct(ctx *TypeBlockStructContext) any { return v.VisitChildren(ctx) } -func (v *BaseApiParserVisitor) VisitTypeBlockAlias(ctx *TypeBlockAliasContext) interface{} { +func (v *BaseApiParserVisitor) VisitTypeBlockAlias(ctx *TypeBlockAliasContext) any { return v.VisitChildren(ctx) } -func (v *BaseApiParserVisitor) VisitField(ctx *FieldContext) interface{} { +func (v *BaseApiParserVisitor) VisitField(ctx *FieldContext) any { return v.VisitChildren(ctx) } -func (v *BaseApiParserVisitor) VisitNormalField(ctx *NormalFieldContext) interface{} { +func (v *BaseApiParserVisitor) VisitNormalField(ctx *NormalFieldContext) any { return v.VisitChildren(ctx) } -func (v *BaseApiParserVisitor) VisitAnonymousFiled(ctx *AnonymousFiledContext) interface{} { +func (v *BaseApiParserVisitor) VisitAnonymousFiled(ctx *AnonymousFiledContext) any { return v.VisitChildren(ctx) } -func (v *BaseApiParserVisitor) VisitDataType(ctx *DataTypeContext) interface{} { +func (v *BaseApiParserVisitor) VisitDataType(ctx *DataTypeContext) any { return v.VisitChildren(ctx) } -func (v *BaseApiParserVisitor) VisitPointerType(ctx *PointerTypeContext) interface{} { +func (v *BaseApiParserVisitor) VisitPointerType(ctx *PointerTypeContext) any { return v.VisitChildren(ctx) } -func (v *BaseApiParserVisitor) VisitMapType(ctx *MapTypeContext) interface{} { +func (v *BaseApiParserVisitor) VisitMapType(ctx *MapTypeContext) any { return v.VisitChildren(ctx) } -func (v *BaseApiParserVisitor) VisitArrayType(ctx *ArrayTypeContext) interface{} { +func (v *BaseApiParserVisitor) VisitArrayType(ctx *ArrayTypeContext) any { return v.VisitChildren(ctx) } -func (v *BaseApiParserVisitor) VisitServiceSpec(ctx *ServiceSpecContext) interface{} { +func (v *BaseApiParserVisitor) VisitServiceSpec(ctx *ServiceSpecContext) any { return v.VisitChildren(ctx) } -func (v *BaseApiParserVisitor) VisitAtServer(ctx *AtServerContext) interface{} { +func (v *BaseApiParserVisitor) VisitAtServer(ctx *AtServerContext) any { return v.VisitChildren(ctx) } -func (v *BaseApiParserVisitor) VisitServiceApi(ctx *ServiceApiContext) interface{} { +func (v *BaseApiParserVisitor) VisitServiceApi(ctx *ServiceApiContext) any { return v.VisitChildren(ctx) } -func (v *BaseApiParserVisitor) VisitServiceRoute(ctx *ServiceRouteContext) interface{} { +func (v *BaseApiParserVisitor) VisitServiceRoute(ctx *ServiceRouteContext) any { return v.VisitChildren(ctx) } -func (v *BaseApiParserVisitor) VisitAtDoc(ctx *AtDocContext) interface{} { +func (v *BaseApiParserVisitor) VisitAtDoc(ctx *AtDocContext) any { return v.VisitChildren(ctx) } -func (v *BaseApiParserVisitor) VisitAtHandler(ctx *AtHandlerContext) interface{} { +func (v *BaseApiParserVisitor) VisitAtHandler(ctx *AtHandlerContext) any { return v.VisitChildren(ctx) } -func (v *BaseApiParserVisitor) VisitRoute(ctx *RouteContext) interface{} { +func (v *BaseApiParserVisitor) VisitRoute(ctx *RouteContext) any { return v.VisitChildren(ctx) } -func (v *BaseApiParserVisitor) VisitBody(ctx *BodyContext) interface{} { +func (v *BaseApiParserVisitor) VisitBody(ctx *BodyContext) any { return v.VisitChildren(ctx) } -func (v *BaseApiParserVisitor) VisitReplybody(ctx *ReplybodyContext) interface{} { +func (v *BaseApiParserVisitor) VisitReplybody(ctx *ReplybodyContext) any { return v.VisitChildren(ctx) } -func (v *BaseApiParserVisitor) VisitKvLit(ctx *KvLitContext) interface{} { +func (v *BaseApiParserVisitor) VisitKvLit(ctx *KvLitContext) any { return v.VisitChildren(ctx) } -func (v *BaseApiParserVisitor) VisitServiceName(ctx *ServiceNameContext) interface{} { +func (v *BaseApiParserVisitor) VisitServiceName(ctx *ServiceNameContext) any { return v.VisitChildren(ctx) } -func (v *BaseApiParserVisitor) VisitPath(ctx *PathContext) interface{} { +func (v *BaseApiParserVisitor) VisitPath(ctx *PathContext) any { return v.VisitChildren(ctx) } -func (v *BaseApiParserVisitor) VisitPathItem(ctx *PathItemContext) interface{} { +func (v *BaseApiParserVisitor) VisitPathItem(ctx *PathItemContext) any { return v.VisitChildren(ctx) } diff --git a/tools/goctl/api/parser/g4/gen/api/apiparser_parser.go b/tools/goctl/api/parser/g4/gen/api/apiparser_parser.go index 02753342..91af67fa 100755 --- a/tools/goctl/api/parser/g4/gen/api/apiparser_parser.go +++ b/tools/goctl/api/parser/g4/gen/api/apiparser_parser.go @@ -360,7 +360,7 @@ func (s *ApiContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) st return antlr.TreesStringTree(s, ruleNames, recog) } -func (s *ApiContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { +func (s *ApiContext) Accept(visitor antlr.ParseTreeVisitor) any { switch t := visitor.(type) { case ApiParserVisitor: return t.VisitApi(s) @@ -506,7 +506,7 @@ func (s *SpecContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) s return antlr.TreesStringTree(s, ruleNames, recog) } -func (s *SpecContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { +func (s *SpecContext) Accept(visitor antlr.ParseTreeVisitor) any { switch t := visitor.(type) { case ApiParserVisitor: return t.VisitSpec(s) diff --git a/tools/goctl/api/parser/g4/gen/api/apiparser_parser1.go b/tools/goctl/api/parser/g4/gen/api/apiparser_parser1.go index 3f2c17e0..5ac06a8c 100755 --- a/tools/goctl/api/parser/g4/gen/api/apiparser_parser1.go +++ b/tools/goctl/api/parser/g4/gen/api/apiparser_parser1.go @@ -22,7 +22,7 @@ func (s *SyntaxLitContext) ToStringTree(ruleNames []string, recog antlr.Recogniz return antlr.TreesStringTree(s, ruleNames, recog) } -func (s *SyntaxLitContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { +func (s *SyntaxLitContext) Accept(visitor antlr.ParseTreeVisitor) any { switch t := visitor.(type) { case ApiParserVisitor: return t.VisitSyntaxLit(s) @@ -146,7 +146,7 @@ func (s *ImportSpecContext) ToStringTree(ruleNames []string, recog antlr.Recogni return antlr.TreesStringTree(s, ruleNames, recog) } -func (s *ImportSpecContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { +func (s *ImportSpecContext) Accept(visitor antlr.ParseTreeVisitor) any { switch t := visitor.(type) { case ApiParserVisitor: return t.VisitImportSpec(s) @@ -269,7 +269,7 @@ func (s *ImportLitContext) ToStringTree(ruleNames []string, recog antlr.Recogniz return antlr.TreesStringTree(s, ruleNames, recog) } -func (s *ImportLitContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { +func (s *ImportLitContext) Accept(visitor antlr.ParseTreeVisitor) any { switch t := visitor.(type) { case ApiParserVisitor: return t.VisitImportLit(s) @@ -400,7 +400,7 @@ func (s *ImportBlockContext) ToStringTree(ruleNames []string, recog antlr.Recogn return antlr.TreesStringTree(s, ruleNames, recog) } -func (s *ImportBlockContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { +func (s *ImportBlockContext) Accept(visitor antlr.ParseTreeVisitor) any { switch t := visitor.(type) { case ApiParserVisitor: return t.VisitImportBlock(s) @@ -522,7 +522,7 @@ func (s *ImportBlockValueContext) ToStringTree(ruleNames []string, recog antlr.R return antlr.TreesStringTree(s, ruleNames, recog) } -func (s *ImportBlockValueContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { +func (s *ImportBlockValueContext) Accept(visitor antlr.ParseTreeVisitor) any { switch t := visitor.(type) { case ApiParserVisitor: return t.VisitImportBlockValue(s) @@ -611,7 +611,7 @@ func (s *ImportValueContext) ToStringTree(ruleNames []string, recog antlr.Recogn return antlr.TreesStringTree(s, ruleNames, recog) } -func (s *ImportValueContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { +func (s *ImportValueContext) Accept(visitor antlr.ParseTreeVisitor) any { switch t := visitor.(type) { case ApiParserVisitor: return t.VisitImportValue(s) diff --git a/tools/goctl/api/parser/g4/gen/api/apiparser_parser2.go b/tools/goctl/api/parser/g4/gen/api/apiparser_parser2.go index 395d4141..d3ec4fb3 100755 --- a/tools/goctl/api/parser/g4/gen/api/apiparser_parser2.go +++ b/tools/goctl/api/parser/g4/gen/api/apiparser_parser2.go @@ -87,7 +87,7 @@ func (s *InfoSpecContext) ToStringTree(ruleNames []string, recog antlr.Recognize return antlr.TreesStringTree(s, ruleNames, recog) } -func (s *InfoSpecContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { +func (s *InfoSpecContext) Accept(visitor antlr.ParseTreeVisitor) any { switch t := visitor.(type) { case ApiParserVisitor: return t.VisitInfoSpec(s) @@ -225,7 +225,7 @@ func (s *TypeSpecContext) ToStringTree(ruleNames []string, recog antlr.Recognize return antlr.TreesStringTree(s, ruleNames, recog) } -func (s *TypeSpecContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { +func (s *TypeSpecContext) Accept(visitor antlr.ParseTreeVisitor) any { switch t := visitor.(type) { case ApiParserVisitor: return t.VisitTypeSpec(s) @@ -348,7 +348,7 @@ func (s *TypeLitContext) ToStringTree(ruleNames []string, recog antlr.Recognizer return antlr.TreesStringTree(s, ruleNames, recog) } -func (s *TypeLitContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { +func (s *TypeLitContext) Accept(visitor antlr.ParseTreeVisitor) any { switch t := visitor.(type) { case ApiParserVisitor: return t.VisitTypeLit(s) @@ -501,7 +501,7 @@ func (s *TypeBlockContext) ToStringTree(ruleNames []string, recog antlr.Recogniz return antlr.TreesStringTree(s, ruleNames, recog) } -func (s *TypeBlockContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { +func (s *TypeBlockContext) Accept(visitor antlr.ParseTreeVisitor) any { switch t := visitor.(type) { case ApiParserVisitor: return t.VisitTypeBlock(s) @@ -639,7 +639,7 @@ func (s *TypeLitBodyContext) ToStringTree(ruleNames []string, recog antlr.Recogn return antlr.TreesStringTree(s, ruleNames, recog) } -func (s *TypeLitBodyContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { +func (s *TypeLitBodyContext) Accept(visitor antlr.ParseTreeVisitor) any { switch t := visitor.(type) { case ApiParserVisitor: return t.VisitTypeLitBody(s) diff --git a/tools/goctl/api/parser/g4/gen/api/apiparser_parser3.go b/tools/goctl/api/parser/g4/gen/api/apiparser_parser3.go index bd9dc816..94e6e402 100755 --- a/tools/goctl/api/parser/g4/gen/api/apiparser_parser3.go +++ b/tools/goctl/api/parser/g4/gen/api/apiparser_parser3.go @@ -76,7 +76,7 @@ func (s *TypeBlockBodyContext) ToStringTree(ruleNames []string, recog antlr.Reco return antlr.TreesStringTree(s, ruleNames, recog) } -func (s *TypeBlockBodyContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { +func (s *TypeBlockBodyContext) Accept(visitor antlr.ParseTreeVisitor) any { switch t := visitor.(type) { case ApiParserVisitor: return t.VisitTypeBlockBody(s) @@ -249,7 +249,7 @@ func (s *TypeStructContext) ToStringTree(ruleNames []string, recog antlr.Recogni return antlr.TreesStringTree(s, ruleNames, recog) } -func (s *TypeStructContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { +func (s *TypeStructContext) Accept(visitor antlr.ParseTreeVisitor) any { switch t := visitor.(type) { case ApiParserVisitor: return t.VisitTypeStruct(s) @@ -421,7 +421,7 @@ func (s *TypeAliasContext) ToStringTree(ruleNames []string, recog antlr.Recogniz return antlr.TreesStringTree(s, ruleNames, recog) } -func (s *TypeAliasContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { +func (s *TypeAliasContext) Accept(visitor antlr.ParseTreeVisitor) any { switch t := visitor.(type) { case ApiParserVisitor: return t.VisitTypeAlias(s) @@ -604,7 +604,7 @@ func (s *TypeBlockStructContext) ToStringTree(ruleNames []string, recog antlr.Re return antlr.TreesStringTree(s, ruleNames, recog) } -func (s *TypeBlockStructContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { +func (s *TypeBlockStructContext) Accept(visitor antlr.ParseTreeVisitor) any { switch t := visitor.(type) { case ApiParserVisitor: return t.VisitTypeBlockStruct(s) diff --git a/tools/goctl/api/parser/g4/gen/api/apiparser_parser4.go b/tools/goctl/api/parser/g4/gen/api/apiparser_parser4.go index dca80711..3aad75b5 100755 --- a/tools/goctl/api/parser/g4/gen/api/apiparser_parser4.go +++ b/tools/goctl/api/parser/g4/gen/api/apiparser_parser4.go @@ -92,7 +92,7 @@ func (s *TypeBlockAliasContext) ToStringTree(ruleNames []string, recog antlr.Rec return antlr.TreesStringTree(s, ruleNames, recog) } -func (s *TypeBlockAliasContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { +func (s *TypeBlockAliasContext) Accept(visitor antlr.ParseTreeVisitor) any { switch t := visitor.(type) { case ApiParserVisitor: return t.VisitTypeBlockAlias(s) @@ -220,7 +220,7 @@ func (s *FieldContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) return antlr.TreesStringTree(s, ruleNames, recog) } -func (s *FieldContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { +func (s *FieldContext) Accept(visitor antlr.ParseTreeVisitor) any { switch t := visitor.(type) { case ApiParserVisitor: return t.VisitField(s) @@ -363,7 +363,7 @@ func (s *NormalFieldContext) ToStringTree(ruleNames []string, recog antlr.Recogn return antlr.TreesStringTree(s, ruleNames, recog) } -func (s *NormalFieldContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { +func (s *NormalFieldContext) Accept(visitor antlr.ParseTreeVisitor) any { switch t := visitor.(type) { case ApiParserVisitor: return t.VisitNormalField(s) @@ -484,7 +484,7 @@ func (s *AnonymousFiledContext) ToStringTree(ruleNames []string, recog antlr.Rec return antlr.TreesStringTree(s, ruleNames, recog) } -func (s *AnonymousFiledContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { +func (s *AnonymousFiledContext) Accept(visitor antlr.ParseTreeVisitor) any { switch t := visitor.(type) { case ApiParserVisitor: return t.VisitAnonymousFiled(s) @@ -654,7 +654,7 @@ func (s *DataTypeContext) ToStringTree(ruleNames []string, recog antlr.Recognize return antlr.TreesStringTree(s, ruleNames, recog) } -func (s *DataTypeContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { +func (s *DataTypeContext) Accept(visitor antlr.ParseTreeVisitor) any { switch t := visitor.(type) { case ApiParserVisitor: return t.VisitDataType(s) diff --git a/tools/goctl/api/parser/g4/gen/api/apiparser_parser5.go b/tools/goctl/api/parser/g4/gen/api/apiparser_parser5.go index 86110111..bcc6d532 100755 --- a/tools/goctl/api/parser/g4/gen/api/apiparser_parser5.go +++ b/tools/goctl/api/parser/g4/gen/api/apiparser_parser5.go @@ -155,7 +155,7 @@ func (s *PointerTypeContext) ToStringTree(ruleNames []string, recog antlr.Recogn return antlr.TreesStringTree(s, ruleNames, recog) } -func (s *PointerTypeContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { +func (s *PointerTypeContext) Accept(visitor antlr.ParseTreeVisitor) any { switch t := visitor.(type) { case ApiParserVisitor: return t.VisitPointerType(s) @@ -321,7 +321,7 @@ func (s *MapTypeContext) ToStringTree(ruleNames []string, recog antlr.Recognizer return antlr.TreesStringTree(s, ruleNames, recog) } -func (s *MapTypeContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { +func (s *MapTypeContext) Accept(visitor antlr.ParseTreeVisitor) any { switch t := visitor.(type) { case ApiParserVisitor: return t.VisitMapType(s) @@ -471,7 +471,7 @@ func (s *ArrayTypeContext) ToStringTree(ruleNames []string, recog antlr.Recogniz return antlr.TreesStringTree(s, ruleNames, recog) } -func (s *ArrayTypeContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { +func (s *ArrayTypeContext) Accept(visitor antlr.ParseTreeVisitor) any { switch t := visitor.(type) { case ApiParserVisitor: return t.VisitArrayType(s) @@ -590,7 +590,7 @@ func (s *ServiceSpecContext) ToStringTree(ruleNames []string, recog antlr.Recogn return antlr.TreesStringTree(s, ruleNames, recog) } -func (s *ServiceSpecContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { +func (s *ServiceSpecContext) Accept(visitor antlr.ParseTreeVisitor) any { switch t := visitor.(type) { case ApiParserVisitor: return t.VisitServiceSpec(s) diff --git a/tools/goctl/api/parser/g4/gen/api/apiparser_parser6.go b/tools/goctl/api/parser/g4/gen/api/apiparser_parser6.go index fa8657d4..79d0e2c5 100755 --- a/tools/goctl/api/parser/g4/gen/api/apiparser_parser6.go +++ b/tools/goctl/api/parser/g4/gen/api/apiparser_parser6.go @@ -82,7 +82,7 @@ func (s *AtServerContext) ToStringTree(ruleNames []string, recog antlr.Recognize return antlr.TreesStringTree(s, ruleNames, recog) } -func (s *AtServerContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { +func (s *AtServerContext) Accept(visitor antlr.ParseTreeVisitor) any { switch t := visitor.(type) { case ApiParserVisitor: return t.VisitAtServer(s) @@ -266,7 +266,7 @@ func (s *ServiceApiContext) ToStringTree(ruleNames []string, recog antlr.Recogni return antlr.TreesStringTree(s, ruleNames, recog) } -func (s *ServiceApiContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { +func (s *ServiceApiContext) Accept(visitor antlr.ParseTreeVisitor) any { switch t := visitor.(type) { case ApiParserVisitor: return t.VisitServiceApi(s) @@ -428,7 +428,7 @@ func (s *ServiceRouteContext) ToStringTree(ruleNames []string, recog antlr.Recog return antlr.TreesStringTree(s, ruleNames, recog) } -func (s *ServiceRouteContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { +func (s *ServiceRouteContext) Accept(visitor antlr.ParseTreeVisitor) any { switch t := visitor.(type) { case ApiParserVisitor: return t.VisitServiceRoute(s) @@ -597,7 +597,7 @@ func (s *AtDocContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) return antlr.TreesStringTree(s, ruleNames, recog) } -func (s *AtDocContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { +func (s *AtDocContext) Accept(visitor antlr.ParseTreeVisitor) any { switch t := visitor.(type) { case ApiParserVisitor: return t.VisitAtDoc(s) diff --git a/tools/goctl/api/parser/g4/gen/api/apiparser_parser7.go b/tools/goctl/api/parser/g4/gen/api/apiparser_parser7.go index 2e22bea5..be6fe0d6 100755 --- a/tools/goctl/api/parser/g4/gen/api/apiparser_parser7.go +++ b/tools/goctl/api/parser/g4/gen/api/apiparser_parser7.go @@ -64,7 +64,7 @@ func (s *AtHandlerContext) ToStringTree(ruleNames []string, recog antlr.Recogniz return antlr.TreesStringTree(s, ruleNames, recog) } -func (s *AtHandlerContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { +func (s *AtHandlerContext) Accept(visitor antlr.ParseTreeVisitor) any { switch t := visitor.(type) { case ApiParserVisitor: return t.VisitAtHandler(s) @@ -220,7 +220,7 @@ func (s *RouteContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) return antlr.TreesStringTree(s, ruleNames, recog) } -func (s *RouteContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { +func (s *RouteContext) Accept(visitor antlr.ParseTreeVisitor) any { switch t := visitor.(type) { case ApiParserVisitor: return t.VisitRoute(s) @@ -368,7 +368,7 @@ func (s *BodyContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) s return antlr.TreesStringTree(s, ruleNames, recog) } -func (s *BodyContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { +func (s *BodyContext) Accept(visitor antlr.ParseTreeVisitor) any { switch t := visitor.(type) { case ApiParserVisitor: return t.VisitBody(s) @@ -518,7 +518,7 @@ func (s *ReplybodyContext) ToStringTree(ruleNames []string, recog antlr.Recogniz return antlr.TreesStringTree(s, ruleNames, recog) } -func (s *ReplybodyContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { +func (s *ReplybodyContext) Accept(visitor antlr.ParseTreeVisitor) any { switch t := visitor.(type) { case ApiParserVisitor: return t.VisitReplybody(s) diff --git a/tools/goctl/api/parser/g4/gen/api/apiparser_parser8.go b/tools/goctl/api/parser/g4/gen/api/apiparser_parser8.go index ef923f40..a73b6dba 100755 --- a/tools/goctl/api/parser/g4/gen/api/apiparser_parser8.go +++ b/tools/goctl/api/parser/g4/gen/api/apiparser_parser8.go @@ -11,7 +11,7 @@ import ( // The apiparser_parser.go file was split into multiple files because it // was too large and caused a possible memory overflow during goctl installation. -func (s *KvLitContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { +func (s *KvLitContext) Accept(visitor antlr.ParseTreeVisitor) any { switch t := visitor.(type) { case ApiParserVisitor: return t.VisitKvLit(s) @@ -115,7 +115,7 @@ func (s *ServiceNameContext) ToStringTree(ruleNames []string, recog antlr.Recogn return antlr.TreesStringTree(s, ruleNames, recog) } -func (s *ServiceNameContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { +func (s *ServiceNameContext) Accept(visitor antlr.ParseTreeVisitor) any { switch t := visitor.(type) { case ApiParserVisitor: return t.VisitServiceName(s) @@ -245,7 +245,7 @@ func (s *PathContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) s return antlr.TreesStringTree(s, ruleNames, recog) } -func (s *PathContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { +func (s *PathContext) Accept(visitor antlr.ParseTreeVisitor) any { switch t := visitor.(type) { case ApiParserVisitor: return t.VisitPath(s) @@ -428,7 +428,7 @@ func (s *PathItemContext) ToStringTree(ruleNames []string, recog antlr.Recognize return antlr.TreesStringTree(s, ruleNames, recog) } -func (s *PathItemContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { +func (s *PathItemContext) Accept(visitor antlr.ParseTreeVisitor) any { switch t := visitor.(type) { case ApiParserVisitor: return t.VisitPathItem(s) diff --git a/tools/goctl/api/parser/g4/gen/api/apiparser_visitor.go b/tools/goctl/api/parser/g4/gen/api/apiparser_visitor.go index d7257f74..7139b055 100644 --- a/tools/goctl/api/parser/g4/gen/api/apiparser_visitor.go +++ b/tools/goctl/api/parser/g4/gen/api/apiparser_visitor.go @@ -8,116 +8,116 @@ type ApiParserVisitor interface { antlr.ParseTreeVisitor // Visit a parse tree produced by ApiParserParser#api. - VisitApi(ctx *ApiContext) interface{} + VisitApi(ctx *ApiContext) any // Visit a parse tree produced by ApiParserParser#spec. - VisitSpec(ctx *SpecContext) interface{} + VisitSpec(ctx *SpecContext) any // Visit a parse tree produced by ApiParserParser#syntaxLit. - VisitSyntaxLit(ctx *SyntaxLitContext) interface{} + VisitSyntaxLit(ctx *SyntaxLitContext) any // Visit a parse tree produced by ApiParserParser#importSpec. - VisitImportSpec(ctx *ImportSpecContext) interface{} + VisitImportSpec(ctx *ImportSpecContext) any // Visit a parse tree produced by ApiParserParser#importLit. - VisitImportLit(ctx *ImportLitContext) interface{} + VisitImportLit(ctx *ImportLitContext) any // Visit a parse tree produced by ApiParserParser#importBlock. - VisitImportBlock(ctx *ImportBlockContext) interface{} + VisitImportBlock(ctx *ImportBlockContext) any // Visit a parse tree produced by ApiParserParser#importBlockValue. - VisitImportBlockValue(ctx *ImportBlockValueContext) interface{} + VisitImportBlockValue(ctx *ImportBlockValueContext) any // Visit a parse tree produced by ApiParserParser#importValue. - VisitImportValue(ctx *ImportValueContext) interface{} + VisitImportValue(ctx *ImportValueContext) any // Visit a parse tree produced by ApiParserParser#infoSpec. - VisitInfoSpec(ctx *InfoSpecContext) interface{} + VisitInfoSpec(ctx *InfoSpecContext) any // Visit a parse tree produced by ApiParserParser#typeSpec. - VisitTypeSpec(ctx *TypeSpecContext) interface{} + VisitTypeSpec(ctx *TypeSpecContext) any // Visit a parse tree produced by ApiParserParser#typeLit. - VisitTypeLit(ctx *TypeLitContext) interface{} + VisitTypeLit(ctx *TypeLitContext) any // Visit a parse tree produced by ApiParserParser#typeBlock. - VisitTypeBlock(ctx *TypeBlockContext) interface{} + VisitTypeBlock(ctx *TypeBlockContext) any // Visit a parse tree produced by ApiParserParser#typeLitBody. - VisitTypeLitBody(ctx *TypeLitBodyContext) interface{} + VisitTypeLitBody(ctx *TypeLitBodyContext) any // Visit a parse tree produced by ApiParserParser#typeBlockBody. - VisitTypeBlockBody(ctx *TypeBlockBodyContext) interface{} + VisitTypeBlockBody(ctx *TypeBlockBodyContext) any // Visit a parse tree produced by ApiParserParser#typeStruct. - VisitTypeStruct(ctx *TypeStructContext) interface{} + VisitTypeStruct(ctx *TypeStructContext) any // Visit a parse tree produced by ApiParserParser#typeAlias. - VisitTypeAlias(ctx *TypeAliasContext) interface{} + VisitTypeAlias(ctx *TypeAliasContext) any // Visit a parse tree produced by ApiParserParser#typeBlockStruct. - VisitTypeBlockStruct(ctx *TypeBlockStructContext) interface{} + VisitTypeBlockStruct(ctx *TypeBlockStructContext) any // Visit a parse tree produced by ApiParserParser#typeBlockAlias. - VisitTypeBlockAlias(ctx *TypeBlockAliasContext) interface{} + VisitTypeBlockAlias(ctx *TypeBlockAliasContext) any // Visit a parse tree produced by ApiParserParser#field. - VisitField(ctx *FieldContext) interface{} + VisitField(ctx *FieldContext) any // Visit a parse tree produced by ApiParserParser#normalField. - VisitNormalField(ctx *NormalFieldContext) interface{} + VisitNormalField(ctx *NormalFieldContext) any // Visit a parse tree produced by ApiParserParser#anonymousFiled. - VisitAnonymousFiled(ctx *AnonymousFiledContext) interface{} + VisitAnonymousFiled(ctx *AnonymousFiledContext) any // Visit a parse tree produced by ApiParserParser#dataType. - VisitDataType(ctx *DataTypeContext) interface{} + VisitDataType(ctx *DataTypeContext) any // Visit a parse tree produced by ApiParserParser#pointerType. - VisitPointerType(ctx *PointerTypeContext) interface{} + VisitPointerType(ctx *PointerTypeContext) any // Visit a parse tree produced by ApiParserParser#mapType. - VisitMapType(ctx *MapTypeContext) interface{} + VisitMapType(ctx *MapTypeContext) any // Visit a parse tree produced by ApiParserParser#arrayType. - VisitArrayType(ctx *ArrayTypeContext) interface{} + VisitArrayType(ctx *ArrayTypeContext) any // Visit a parse tree produced by ApiParserParser#serviceSpec. - VisitServiceSpec(ctx *ServiceSpecContext) interface{} + VisitServiceSpec(ctx *ServiceSpecContext) any // Visit a parse tree produced by ApiParserParser#atServer. - VisitAtServer(ctx *AtServerContext) interface{} + VisitAtServer(ctx *AtServerContext) any // Visit a parse tree produced by ApiParserParser#serviceApi. - VisitServiceApi(ctx *ServiceApiContext) interface{} + VisitServiceApi(ctx *ServiceApiContext) any // Visit a parse tree produced by ApiParserParser#serviceRoute. - VisitServiceRoute(ctx *ServiceRouteContext) interface{} + VisitServiceRoute(ctx *ServiceRouteContext) any // Visit a parse tree produced by ApiParserParser#atDoc. - VisitAtDoc(ctx *AtDocContext) interface{} + VisitAtDoc(ctx *AtDocContext) any // Visit a parse tree produced by ApiParserParser#atHandler. - VisitAtHandler(ctx *AtHandlerContext) interface{} + VisitAtHandler(ctx *AtHandlerContext) any // Visit a parse tree produced by ApiParserParser#route. - VisitRoute(ctx *RouteContext) interface{} + VisitRoute(ctx *RouteContext) any // Visit a parse tree produced by ApiParserParser#body. - VisitBody(ctx *BodyContext) interface{} + VisitBody(ctx *BodyContext) any // Visit a parse tree produced by ApiParserParser#replybody. - VisitReplybody(ctx *ReplybodyContext) interface{} + VisitReplybody(ctx *ReplybodyContext) any // Visit a parse tree produced by ApiParserParser#kvLit. - VisitKvLit(ctx *KvLitContext) interface{} + VisitKvLit(ctx *KvLitContext) any // Visit a parse tree produced by ApiParserParser#serviceName. - VisitServiceName(ctx *ServiceNameContext) interface{} + VisitServiceName(ctx *ServiceNameContext) any // Visit a parse tree produced by ApiParserParser#path. - VisitPath(ctx *PathContext) interface{} + VisitPath(ctx *PathContext) any // Visit a parse tree produced by ApiParserParser#pathItem. - VisitPathItem(ctx *PathItemContext) interface{} + VisitPathItem(ctx *PathItemContext) any } diff --git a/tools/goctl/api/parser/g4/test/ast_test.go b/tools/goctl/api/parser/g4/test/ast_test.go index cbd23717..4acebc12 100644 --- a/tools/goctl/api/parser/g4/test/ast_test.go +++ b/tools/goctl/api/parser/g4/test/ast_test.go @@ -15,7 +15,7 @@ var testApi string var parser = ast.NewParser(ast.WithParserPrefix("test.api"), ast.WithParserDebug()) func TestApi(t *testing.T) { - fn := func(p *api.ApiParserParser, visitor *ast.ApiVisitor) interface{} { + fn := func(p *api.ApiParserParser, visitor *ast.ApiVisitor) any { return p.Api().Accept(visitor) } @@ -445,7 +445,7 @@ func TestApi(t *testing.T) { } func TestApiSyntax(t *testing.T) { - fn := func(p *api.ApiParserParser, visitor *ast.ApiVisitor) interface{} { + fn := func(p *api.ApiParserParser, visitor *ast.ApiVisitor) any { return p.Api().Accept(visitor) } parser.Accept(fn, ` diff --git a/tools/goctl/api/parser/g4/test/import_test.go b/tools/goctl/api/parser/g4/test/import_test.go index 422ae0c6..6f757ac0 100644 --- a/tools/goctl/api/parser/g4/test/import_test.go +++ b/tools/goctl/api/parser/g4/test/import_test.go @@ -9,7 +9,7 @@ import ( "github.com/zeromicro/go-zero/tools/goctl/api/parser/g4/gen/api" ) -var importAccept = func(p *api.ApiParserParser, visitor *ast.ApiVisitor) interface{} { +var importAccept = func(p *api.ApiParserParser, visitor *ast.ApiVisitor) any { return p.ImportSpec().Accept(visitor) } diff --git a/tools/goctl/api/parser/g4/test/info_test.go b/tools/goctl/api/parser/g4/test/info_test.go index 2ce1f91c..76f0adb7 100644 --- a/tools/goctl/api/parser/g4/test/info_test.go +++ b/tools/goctl/api/parser/g4/test/info_test.go @@ -8,7 +8,7 @@ import ( "github.com/zeromicro/go-zero/tools/goctl/api/parser/g4/gen/api" ) -var infoAccept = func(p *api.ApiParserParser, visitor *ast.ApiVisitor) interface{} { +var infoAccept = func(p *api.ApiParserParser, visitor *ast.ApiVisitor) any { return p.InfoSpec().Accept(visitor) } diff --git a/tools/goctl/api/parser/g4/test/service_test.go b/tools/goctl/api/parser/g4/test/service_test.go index e1ccdc63..61747315 100644 --- a/tools/goctl/api/parser/g4/test/service_test.go +++ b/tools/goctl/api/parser/g4/test/service_test.go @@ -9,7 +9,7 @@ import ( ) func TestBody(t *testing.T) { - fn := func(p *api.ApiParserParser, v *ast.ApiVisitor) interface{} { + fn := func(p *api.ApiParserParser, v *ast.ApiVisitor) any { return p.Body().Accept(v) } t.Run("normal", func(t *testing.T) { @@ -33,7 +33,7 @@ func TestBody(t *testing.T) { } func TestRoute(t *testing.T) { - fn := func(p *api.ApiParserParser, v *ast.ApiVisitor) interface{} { + fn := func(p *api.ApiParserParser, v *ast.ApiVisitor) any { return p.Route().Accept(v) } t.Run("normal", func(t *testing.T) { @@ -196,7 +196,7 @@ func TestRoute(t *testing.T) { } func TestAtHandler(t *testing.T) { - fn := func(p *api.ApiParserParser, v *ast.ApiVisitor) interface{} { + fn := func(p *api.ApiParserParser, v *ast.ApiVisitor) any { return p.AtHandler().Accept(v) } t.Run("normal", func(t *testing.T) { @@ -236,7 +236,7 @@ func TestAtHandler(t *testing.T) { } func TestAtDoc(t *testing.T) { - fn := func(p *api.ApiParserParser, v *ast.ApiVisitor) interface{} { + fn := func(p *api.ApiParserParser, v *ast.ApiVisitor) any { return p.AtDoc().Accept(v) } t.Run("normal", func(t *testing.T) { @@ -308,7 +308,7 @@ func TestAtDoc(t *testing.T) { } func TestServiceRoute(t *testing.T) { - fn := func(p *api.ApiParserParser, v *ast.ApiVisitor) interface{} { + fn := func(p *api.ApiParserParser, v *ast.ApiVisitor) any { return p.ServiceRoute().Accept(v) } t.Run("normal", func(t *testing.T) { @@ -370,7 +370,7 @@ func TestServiceRoute(t *testing.T) { } func TestServiceApi(t *testing.T) { - fn := func(p *api.ApiParserParser, v *ast.ApiVisitor) interface{} { + fn := func(p *api.ApiParserParser, v *ast.ApiVisitor) any { return p.ServiceApi().Accept(v) } t.Run("normal", func(t *testing.T) { @@ -452,7 +452,7 @@ func TestServiceApi(t *testing.T) { } func TestAtServer(t *testing.T) { - fn := func(p *api.ApiParserParser, v *ast.ApiVisitor) interface{} { + fn := func(p *api.ApiParserParser, v *ast.ApiVisitor) any { return p.AtServer().Accept(v) } t.Run("normal", func(t *testing.T) { @@ -520,7 +520,7 @@ func TestAtServer(t *testing.T) { } func TestServiceSpec(t *testing.T) { - fn := func(p *api.ApiParserParser, v *ast.ApiVisitor) interface{} { + fn := func(p *api.ApiParserParser, v *ast.ApiVisitor) any { return p.ServiceSpec().Accept(v) } t.Run("normal", func(t *testing.T) { diff --git a/tools/goctl/api/parser/g4/test/syntax_test.go b/tools/goctl/api/parser/g4/test/syntax_test.go index 31af5536..75272272 100644 --- a/tools/goctl/api/parser/g4/test/syntax_test.go +++ b/tools/goctl/api/parser/g4/test/syntax_test.go @@ -8,7 +8,7 @@ import ( "github.com/zeromicro/go-zero/tools/goctl/api/parser/g4/gen/api" ) -var syntaxAccept = func(p *api.ApiParserParser, visitor *ast.ApiVisitor) interface{} { +var syntaxAccept = func(p *api.ApiParserParser, visitor *ast.ApiVisitor) any { return p.SyntaxLit().Accept(visitor) } diff --git a/tools/goctl/api/parser/g4/test/type_test.go b/tools/goctl/api/parser/g4/test/type_test.go index 5a8d0c3e..8e03a0e3 100644 --- a/tools/goctl/api/parser/g4/test/type_test.go +++ b/tools/goctl/api/parser/g4/test/type_test.go @@ -8,7 +8,7 @@ import ( "github.com/zeromicro/go-zero/tools/goctl/api/parser/g4/gen/api" ) -var fieldAccept = func(p *api.ApiParserParser, visitor *ast.ApiVisitor) interface{} { +var fieldAccept = func(p *api.ApiParserParser, visitor *ast.ApiVisitor) any { return p.Field().Accept(visitor) } @@ -93,7 +93,7 @@ func TestField(t *testing.T) { } func TestDataType_ID(t *testing.T) { - dt := func(p *api.ApiParserParser, visitor *ast.ApiVisitor) interface{} { + dt := func(p *api.ApiParserParser, visitor *ast.ApiVisitor) any { return p.DataType().Accept(visitor) } t.Run("Struct", func(t *testing.T) { @@ -117,7 +117,7 @@ func TestDataType_ID(t *testing.T) { } func TestDataType_Map(t *testing.T) { - dt := func(p *api.ApiParserParser, visitor *ast.ApiVisitor) interface{} { + dt := func(p *api.ApiParserParser, visitor *ast.ApiVisitor) any { return p.MapType().Accept(visitor) } t.Run("basicKey", func(t *testing.T) { @@ -147,7 +147,7 @@ func TestDataType_Map(t *testing.T) { } func TestDataType_Array(t *testing.T) { - dt := func(p *api.ApiParserParser, visitor *ast.ApiVisitor) interface{} { + dt := func(p *api.ApiParserParser, visitor *ast.ApiVisitor) any { return p.ArrayType().Accept(visitor) } t.Run("basic", func(t *testing.T) { @@ -200,7 +200,7 @@ func TestDataType_Array(t *testing.T) { } func TestDataType_Interface(t *testing.T) { - dt := func(p *api.ApiParserParser, visitor *ast.ApiVisitor) interface{} { + dt := func(p *api.ApiParserParser, visitor *ast.ApiVisitor) any { return p.DataType().Accept(visitor) } t.Run("normal", func(t *testing.T) { @@ -222,7 +222,7 @@ func TestDataType_Interface(t *testing.T) { } func TestDataType_Time(t *testing.T) { - dt := func(p *api.ApiParserParser, visitor *ast.ApiVisitor) interface{} { + dt := func(p *api.ApiParserParser, visitor *ast.ApiVisitor) any { return p.DataType().Accept(visitor) } t.Run("normal", func(t *testing.T) { @@ -232,7 +232,7 @@ func TestDataType_Time(t *testing.T) { } func TestDataType_Pointer(t *testing.T) { - dt := func(p *api.ApiParserParser, visitor *ast.ApiVisitor) interface{} { + dt := func(p *api.ApiParserParser, visitor *ast.ApiVisitor) any { return p.PointerType().Accept(visitor) } t.Run("normal", func(t *testing.T) { @@ -252,7 +252,7 @@ func TestDataType_Pointer(t *testing.T) { } func TestAlias(t *testing.T) { - fn := func(p *api.ApiParserParser, visitor *ast.ApiVisitor) interface{} { + fn := func(p *api.ApiParserParser, visitor *ast.ApiVisitor) any { return p.TypeAlias().Accept(visitor) } t.Run("normal", func(t *testing.T) { @@ -281,7 +281,7 @@ func TestAlias(t *testing.T) { } func TestTypeStruct(t *testing.T) { - fn := func(p *api.ApiParserParser, visitor *ast.ApiVisitor) interface{} { + fn := func(p *api.ApiParserParser, visitor *ast.ApiVisitor) any { return p.TypeStruct().Accept(visitor) } @@ -330,7 +330,7 @@ func TestTypeStruct(t *testing.T) { } func TestTypeBlock(t *testing.T) { - fn := func(p *api.ApiParserParser, visitor *ast.ApiVisitor) interface{} { + fn := func(p *api.ApiParserParser, visitor *ast.ApiVisitor) any { return p.TypeBlock().Accept(visitor) } t.Run("normal", func(t *testing.T) { @@ -366,7 +366,7 @@ func TestTypeBlock(t *testing.T) { } func TestTypeLit(t *testing.T) { - fn := func(p *api.ApiParserParser, visitor *ast.ApiVisitor) interface{} { + fn := func(p *api.ApiParserParser, visitor *ast.ApiVisitor) any { return p.TypeLit().Accept(visitor) } t.Run("normal", func(t *testing.T) { @@ -435,7 +435,7 @@ func TestTypeLit(t *testing.T) { } func TestTypeUnExported(t *testing.T) { - fn := func(p *api.ApiParserParser, visitor *ast.ApiVisitor) interface{} { + fn := func(p *api.ApiParserParser, visitor *ast.ApiVisitor) any { return p.TypeSpec().Accept(visitor) } diff --git a/tools/goctl/api/spec/name.go b/tools/goctl/api/spec/name.go index 705f145d..9b561058 100644 --- a/tools/goctl/api/spec/name.go +++ b/tools/goctl/api/spec/name.go @@ -75,7 +75,7 @@ func (t PointerType) Documents() []string { return nil } -// Name returns an interface string, Its fixed value is interface{} +// Name returns an interface string, Its fixed value is any func (t InterfaceType) Name() string { return t.RawName } diff --git a/tools/goctl/cmd/usage.go b/tools/goctl/cmd/usage.go index bc1304f0..9daa3dcc 100644 --- a/tools/goctl/cmd/usage.go +++ b/tools/goctl/cmd/usage.go @@ -8,23 +8,23 @@ import ( "github.com/zeromicro/go-zero/tools/goctl/vars" ) -var colorRender = []func(v interface{}) string{ - func(v interface{}) string { +var colorRender = []func(v any) string{ + func(v any) string { return aurora.BrightRed(v).String() }, - func(v interface{}) string { + func(v any) string { return aurora.BrightGreen(v).String() }, - func(v interface{}) string { + func(v any) string { return aurora.BrightYellow(v).String() }, - func(v interface{}) string { + func(v any) string { return aurora.BrightBlue(v).String() }, - func(v interface{}) string { + func(v any) string { return aurora.BrightMagenta(v).String() }, - func(v interface{}) string { + func(v any) string { return aurora.BrightCyan(v).String() }, } diff --git a/tools/goctl/go.mod b/tools/goctl/go.mod index 8c2f6d97..9a40fa78 100644 --- a/tools/goctl/go.mod +++ b/tools/goctl/go.mod @@ -1,6 +1,6 @@ module github.com/zeromicro/go-zero/tools/goctl -go 1.16 +go 1.18 require ( github.com/DATA-DOG/go-sqlmock v1.5.0 @@ -8,11 +8,10 @@ require ( github.com/fatih/structtag v1.2.0 github.com/go-sql-driver/mysql v1.7.0 github.com/iancoleman/strcase v0.2.0 - github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/logrusorgru/aurora v2.0.3+incompatible github.com/spf13/cobra v1.6.1 github.com/stretchr/testify v1.7.1 - github.com/withfig/autocomplete-tools/integrations/cobra v0.0.0-20220705165518-2761d7f4b8bc + github.com/withfig/autocomplete-tools/integrations/cobra v1.2.1 github.com/zeromicro/antlr v0.0.1 github.com/zeromicro/ddl-parser v1.0.4 github.com/zeromicro/go-zero v1.3.4 @@ -20,3 +19,72 @@ require ( google.golang.org/grpc v1.46.2 google.golang.org/protobuf v1.28.0 ) + +require ( + github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a // indirect + github.com/alicebob/miniredis/v2 v2.21.0 // indirect + github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20210521184019-c5ad59b459ec // indirect + github.com/beorn7/perks v1.0.1 // indirect + github.com/cespare/xxhash/v2 v2.1.2 // indirect + github.com/coreos/go-semver v0.3.0 // indirect + github.com/coreos/go-systemd/v22 v22.3.2 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect + github.com/fatih/color v1.13.0 // indirect + github.com/go-logr/logr v1.2.3 // indirect + github.com/go-logr/stdr v1.2.2 // indirect + github.com/go-redis/redis/v8 v8.11.5 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/mock v1.6.0 // indirect + github.com/golang/protobuf v1.5.2 // indirect + github.com/google/go-cmp v0.5.7 // indirect + github.com/google/gofuzz v1.2.0 // indirect + github.com/googleapis/gnostic v0.5.5 // indirect + github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/json-iterator/go v1.1.12 // indirect + github.com/lib/pq v1.10.6 // indirect + github.com/mattn/go-colorable v0.1.9 // indirect + github.com/mattn/go-isatty v0.0.14 // indirect + github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/openzipkin/zipkin-go v0.4.0 // indirect + github.com/pelletier/go-toml/v2 v2.0.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/prometheus/client_golang v1.12.2 // indirect + github.com/prometheus/client_model v0.2.0 // indirect + github.com/prometheus/common v0.32.1 // indirect + github.com/prometheus/procfs v0.7.3 // indirect + github.com/spaolacci/murmur3 v1.1.0 // indirect + github.com/spf13/pflag v1.0.5 // indirect + github.com/yuin/gopher-lua v0.0.0-20210529063254-f4c35e4016d9 // indirect + go.etcd.io/etcd/api/v3 v3.5.4 // indirect + go.etcd.io/etcd/client/pkg/v3 v3.5.4 // indirect + go.etcd.io/etcd/client/v3 v3.5.4 // indirect + go.opentelemetry.io/otel v1.7.0 // indirect + go.opentelemetry.io/otel/exporters/jaeger v1.7.0 // indirect + go.opentelemetry.io/otel/exporters/zipkin v1.7.0 // indirect + go.opentelemetry.io/otel/sdk v1.7.0 // indirect + go.opentelemetry.io/otel/trace v1.7.0 // indirect + go.uber.org/atomic v1.9.0 // indirect + go.uber.org/automaxprocs v1.5.1 // indirect + go.uber.org/multierr v1.8.0 // indirect + go.uber.org/zap v1.21.0 // indirect + golang.org/x/net v0.0.0-20220421235706-1d1ef9303861 // indirect + golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c // indirect + golang.org/x/sys v0.0.0-20220429233432-b5fbb4746d32 // indirect + golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect + golang.org/x/time v0.0.0-20220411224347-583f2d630306 // indirect + google.golang.org/appengine v1.6.6 // indirect + google.golang.org/genproto v0.0.0-20220422154200-b37d22cd5731 // indirect + gopkg.in/inf.v0 v0.9.1 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect + k8s.io/api v0.22.9 // indirect + k8s.io/apimachinery v0.22.9 // indirect + k8s.io/client-go v0.22.9 // indirect + k8s.io/klog/v2 v2.40.1 // indirect + k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect + sigs.k8s.io/yaml v1.2.0 // indirect +) diff --git a/tools/goctl/go.sum b/tools/goctl/go.sum index fa20c6b4..bd252292 100644 --- a/tools/goctl/go.sum +++ b/tools/goctl/go.sum @@ -13,20 +13,6 @@ cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKV cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= -cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI= -cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk= -cloud.google.com/go v0.78.0/go.mod h1:QjdrLG0uq+YwhjoVOLsS1t7TW8fs36kLs4XO5R5ECHg= -cloud.google.com/go v0.79.0/go.mod h1:3bzgcEeQlzbuEAYu4mrWhKqWjmpprinYgKJLgKHnbb8= -cloud.google.com/go v0.81.0/go.mod h1:mk/AM35KwGk/Nm2YSeZbxXdrNK3KZOYHmLkOqC2V6E0= -cloud.google.com/go v0.83.0/go.mod h1:Z7MJUsANfY0pYPdw0lbnivPx4/vhy/e2FEkSkF7vAVY= -cloud.google.com/go v0.84.0/go.mod h1:RazrYuxIK6Kb7YrzzhPoLmCVzl7Sup4NrbKPg8KHSUM= -cloud.google.com/go v0.87.0/go.mod h1:TpDYlFy7vuLzZMMZ+B6iRiELaY7z/gJPaqbMx6mlWcY= -cloud.google.com/go v0.90.0/go.mod h1:kRX0mNRHe0e2rC6oNakvwQqzyDmg57xJ+SZU1eT2aDQ= -cloud.google.com/go v0.93.3/go.mod h1:8utlLll2EF5XMAV15woO4lSbWQlk8rer9aLOfLh7+YI= -cloud.google.com/go v0.94.1/go.mod h1:qAlAugsXlC+JWO+Bke5vCtc9ONxjQT3drlTTnAplMW4= -cloud.google.com/go v0.97.0/go.mod h1:GF7l59pYBVlXQIBLx3a761cZ41F9bBH3JUlihCt2Udc= -cloud.google.com/go v0.98.0/go.mod h1:ua6Ush4NALrHk5QXDWnjvZHN93OuF0HfuEPq9I1X0cM= -cloud.google.com/go v0.99.0/go.mod h1:w0Xx2nLzqWJPuozYQX+hFfCSI8WioryfRDzkoI/Y2ZA= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= @@ -35,7 +21,6 @@ cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4g cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= -cloud.google.com/go/firestore v1.6.1/go.mod h1:asNXNOzBdyVQmEU+ggO8UPodTkEVFW5Qx+rwHnAz+EY= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= @@ -59,9 +44,7 @@ github.com/ClickHouse/clickhouse-go v1.5.4/go.mod h1:EaI/sW7Azgz9UATzd5ZdZHRUhHg github.com/ClickHouse/clickhouse-go/v2 v2.0.14/go.mod h1:iq2DUGgpA4BBki2CVwrF8x43zqBjdgHtbexkFkh5a6M= github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= -github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= -github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/Shopify/sarama v1.30.0/go.mod h1:zujlQQx1kzHsh4jfV1USnptCQrHAEZ2Hk8fTKCulPVs= @@ -79,11 +62,6 @@ github.com/alicebob/miniredis/v2 v2.21.0/go.mod h1:XNqvJdQJv5mSuVMc0ynneafpnL/zv github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20210521184019-c5ad59b459ec h1:EEyRvzmpEUZ+I8WmD5cw/vY8EqhambkOqy5iFr0908A= github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20210521184019-c5ad59b459ec/go.mod h1:F7bn7fEU90QkQ3tnmaTx3LTKLEDqnwWODIYppRQ5hnY= -github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= -github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= -github.com/armon/go-metrics v0.3.10/go.mod h1:4O98XIr/9W0sxpJ8UaYkvjk10Iff7SnFrb4QAOwNTFc= -github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= @@ -91,38 +69,28 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24 github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bkaradzic/go-lz4 v1.0.0/go.mod h1:0YdlkowM3VswSROI7qDxhRvJ3sLhlFrRRwjwegp5jy4= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/census-instrumentation/opencensus-proto v0.3.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= -github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= -github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58/go.mod h1:EOBUe0h4xcZ5GoxqC5SDxFQ8gwyZPKQoEzownBlhI80= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= -github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211130200136-a8f946100490/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd/v22 v22.3.2 h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzAJc1DzSI= github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= -github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -142,18 +110,12 @@ github.com/emicklei/proto v1.11.1/go.mod h1:rn1FgRS/FANiZdD2djyH7TMA9jdRDcYQ9IEN github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= -github.com/envoyproxy/go-control-plane v0.10.1/go.mod h1:AY7fTTXNdv/aJ2O5jwpxAPOWUZ7hQAEvzN5Pf27BkQQ= github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/envoyproxy/protoc-gen-validate v0.6.2/go.mod h1:2t7qjJNvHPx8IjnBOzl9E9/baC+qXE/TeeyBRzgJDws= github.com/evanphx/json-patch v4.11.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= -github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fatih/structtag v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4= @@ -163,9 +125,8 @@ github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod h1:pbq4aXjuKjdthFRnoD github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= -github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI= -github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= @@ -214,7 +175,6 @@ github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= -github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -232,11 +192,9 @@ github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QD github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= @@ -249,7 +207,6 @@ github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= @@ -261,8 +218,6 @@ github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= @@ -270,14 +225,7 @@ github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -285,8 +233,6 @@ github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= -github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM= github.com/googleapis/gnostic v0.5.1/go.mod h1:6U4PtQXGIEt/Z3h5MAT7FNofLnw9vXk2cUuW7uA/OeU= github.com/googleapis/gnostic v0.5.5 h1:9fHAtK0uDfpveeqqo1hkEZJcFvYXAiCN3UutL8F9xHw= github.com/googleapis/gnostic v0.5.5/go.mod h1:7+EbHbldMins07ALC74bsA81Ovc97DwqyJO1AENw9kA= @@ -301,44 +247,15 @@ github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgf github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw= github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI= -github.com/hashicorp/consul/api v1.11.0/go.mod h1:XjsvQN+RJGWI2TWy1/kqaE16HrR2J/FWgkYjdZQsX9M= -github.com/hashicorp/consul/sdk v0.8.0/go.mod h1:GBvyrGALthsZObzUGsfgHZQDXjg4lOjagTIwIR1vPms= -github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= -github.com/hashicorp/go-hclog v0.12.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= -github.com/hashicorp/go-hclog v1.0.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= -github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= -github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= -github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= -github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= -github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA= -github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= -github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= -github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= -github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= -github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= -github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= -github.com/hashicorp/mdns v1.0.1/go.mod h1:4gW7WsVCke5TE7EPeYliwHlRUyBtfCwuFwuMg2DmyNY= -github.com/hashicorp/mdns v1.0.4/go.mod h1:mtBihi+LeNXGtG8L9dX59gAEa12BDtBQSp4v/YAJqrc= -github.com/hashicorp/memberlist v0.2.2/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= -github.com/hashicorp/memberlist v0.3.0/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= -github.com/hashicorp/serf v0.9.5/go.mod h1:UWDWwZeL5cuWDJdl0C6wrvrUwEqtQ4ZKBKKENpqIUyk= -github.com/hashicorp/serf v0.9.6/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/iancoleman/strcase v0.2.0 h1:05I4QRnGpI0m37iZQRuskXh+w77mr6Z41lwQzuHLwW0= github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= -github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= @@ -351,7 +268,6 @@ github.com/jcmturner/rpc/v2 v2.0.3/go.mod h1:VUJYCIDm3PVOEHw8sgt091/20OJjskO/YJk github.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhBSsks= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= @@ -366,7 +282,6 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= @@ -381,20 +296,10 @@ github.com/lib/pq v1.10.6 h1:jbk+ZieJ0D7EVGJYpL9QTz7/YW6UHbmdnZWYyK5cdBs= github.com/lib/pq v1.10.6/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/logrusorgru/aurora v2.0.3+incompatible h1:tOpm7WcpBTn4fjmVfgpQq0EfczGlG91VSDkswnjF5A8= github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= -github.com/lyft/protoc-gen-star v0.5.3/go.mod h1:V0xaHgaf5oCCqmcxYcWiDfTiKsZsRc87/1qhoTACD8w= -github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= -github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= -github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-colorable v0.1.9 h1:sqDoxXbdeALODt0DAeJCVp38ps9ZogZEAXjus69YV3U= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40= -github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= -github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= -github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= @@ -404,15 +309,7 @@ github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOq github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI= github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= -github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= -github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= -github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI= -github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI= -github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= -github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mkevac/debugcharts v0.0.0-20191222103121-ae1c48aa8615/go.mod h1:Ad7oeElCZqA1Ufj0U9/liOF4BtVepxRcTvr2ey7zTvM= github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -450,12 +347,8 @@ github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE= github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs= github.com/openzipkin/zipkin-go v0.4.0 h1:CtfRrOVZtbDj8rt1WXjklw0kqqJQwICrCKmlfUuBUUw= github.com/openzipkin/zipkin-go v0.4.0/go.mod h1:4c3sLeE8xjNqehmF5RpAFLPLJxXscc0R4l6Zg0P1tTQ= -github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= -github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/paulmach/orb v0.5.0/go.mod h1:FWRlTgl88VI1RBx/MkrwWDRhQ96ctqMCh8boXhmqB/A= github.com/paulmach/protoscan v0.2.1/go.mod h1:SpcSwydNLrxUGSDvXvO0P7g7AuhJ7lcKfDlhJCDw2gY= -github.com/pelletier/go-toml v1.9.4 h1:tjENF6MfZAg8e4ZmZTeWaWiT2vXtsoO6+iuOjFhECwM= -github.com/pelletier/go-toml v1.9.4/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/pelletier/go-toml/v2 v2.0.1 h1:8e3L2cCQzLFi2CR4g7vGFuFxX7Jl1kKX8gW+iV0GUKU= github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= @@ -466,16 +359,12 @@ github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= -github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g= github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= -github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= github.com/prometheus/client_golang v1.11.1/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= @@ -487,14 +376,12 @@ github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1: github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M= github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= github.com/prometheus/common v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4= github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU= @@ -506,9 +393,6 @@ github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6L github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= -github.com/sagikazarmark/crypt v0.3.0/go.mod h1:uD/D+6UF4SrIR1uGEv7bBNkNqLGqUr43MRiaGWX1Nig= -github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/shirou/gopsutil v2.19.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc= @@ -518,21 +402,14 @@ github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPx github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= -github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= -github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4= -github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= -github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cobra v1.3.0/go.mod h1:BrRVncBjOJa/eUcVVm9CE+oC6as8k+VYr4NY7WCi9V4= github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA= github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY= -github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/spf13/viper v1.10.0/go.mod h1:SoyBPwAtKDzypXNDFKN5kzH7ppppbGZtls1UpIy5AsM= github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= @@ -545,14 +422,12 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk= github.com/tklauser/numcpus v0.4.0/go.mod h1:1+UI3pD8NW14VMwdgJNJ1ESk2UnwhAnz5hMwiKKqXCQ= -github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= -github.com/withfig/autocomplete-tools/integrations/cobra v0.0.0-20220705165518-2761d7f4b8bc h1:2pGkMttK5jQ8+6YhdyeQIHyVa84HMdJhILozImSWX6c= -github.com/withfig/autocomplete-tools/integrations/cobra v0.0.0-20220705165518-2761d7f4b8bc/go.mod h1:nmuySobZb4kFgFy6BptpXp/BBw+xFSyvVPP6auoJB4k= +github.com/withfig/autocomplete-tools/integrations/cobra v1.2.1 h1:+dBg5k7nuTE38VVdoroRsT0Z88fmvdYrI2EjzJst35I= +github.com/withfig/autocomplete-tools/integrations/cobra v1.2.1/go.mod h1:nmuySobZb4kFgFy6BptpXp/BBw+xFSyvVPP6auoJB4k= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs= github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM= @@ -570,13 +445,10 @@ github.com/zeromicro/ddl-parser v1.0.4 h1:fzU0ZNfV/a6T/WO8TvZZeJE9hmdt3qHvVUsW1X github.com/zeromicro/ddl-parser v1.0.4/go.mod h1:ISU/8NuPyEpl9pa17Py9TBPetMjtsiHrb9f5XGiYbo8= github.com/zeromicro/go-zero v1.3.4 h1:XeNdwcrOmnvHj891AmeCA9RrRj1PeN49//KKCK4WAXk= github.com/zeromicro/go-zero v1.3.4/go.mod h1:nEU/ITZSmxRxvr/JmSoJ48MNV62UpY6bqJz9Voba7Yw= -go.etcd.io/etcd/api/v3 v3.5.1/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= go.etcd.io/etcd/api/v3 v3.5.4 h1:OHVyt3TopwtUQ2GKdd5wu3PmmipR4FTwCqoEjSyRdIc= go.etcd.io/etcd/api/v3 v3.5.4/go.mod h1:5GB2vv4A4AOn3yk7MftYGHkUfGtDHnEraIjym4dYz5A= -go.etcd.io/etcd/client/pkg/v3 v3.5.1/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g= go.etcd.io/etcd/client/pkg/v3 v3.5.4 h1:lrneYvz923dvC14R54XcA7FXoZ3mlGZAgmwhfm7HqOg= go.etcd.io/etcd/client/pkg/v3 v3.5.4/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g= -go.etcd.io/etcd/client/v2 v2.305.1/go.mod h1:pMEacxZW7o8pg4CrFE7pquyCJJzZvkvdD2RibOCCCGs= go.etcd.io/etcd/client/v3 v3.5.4 h1:p83BUL3tAYS0OT/r0qglgc3M1JjhM0diV8DSWAhVXv4= go.etcd.io/etcd/client/v3 v3.5.4/go.mod h1:ZaRkVgBZC+L+dLCjTcF1hRXpgZXQPOvnA/Ak/gq3kiY= go.mongodb.org/mongo-driver v1.9.1/go.mod h1:0sQWfOeY63QTntERDJJ/0SuKK0T1uVSgKCuAROlKEPY= @@ -585,8 +457,6 @@ go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= -go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.opentelemetry.io/otel v1.7.0 h1:Z2lA3Tdch0iDcrhJXDIlC94XE+bxok1F9B+4Lz/lGsM= go.opentelemetry.io/otel v1.7.0/go.mod h1:5BdUoMIz5WEs0vt0CUEMtSSaTSHBBVwrhnz7+nrD5xk= go.opentelemetry.io/otel/exporters/jaeger v1.7.0 h1:wXgjiRldljksZkZrldGVe6XrG9u3kYDyQmkZwmm5dI0= @@ -613,19 +483,15 @@ go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= go.uber.org/zap v1.21.0 h1:WefMeulhovoZ2sYXz7st6K0sLj7bBhpiFaud4r4zST8= go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201112155050-0c6587e931a9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201216223049-8b5274cf687f/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= -golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -649,7 +515,6 @@ golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= @@ -659,14 +524,10 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.5.0/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -680,7 +541,6 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -697,18 +557,10 @@ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8= golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= -golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210917221730-978cfadd31cf/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211209124913-491a49abca63/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220421235706-1d1ef9303861 h1:yssD99+7tqHWO5Gwh81phT+67hg+KttniBr6UnEXOY8= @@ -718,19 +570,8 @@ golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4Iltr golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c h1:pkQiBZBvdos9qq4wBAHqlzuZHEXo07pqV06ef90u1WI= golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 h1:RerP+noqYHUQ8CMRcPlC2nvTa4dcBIjegkuWdcUDuqg= -golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -742,15 +583,12 @@ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190204203706-41f3e6584952/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -760,11 +598,8 @@ golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -774,7 +609,6 @@ golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -789,38 +623,20 @@ golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210603125802-9665404d3644/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211205182925-97ca703d548d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -836,7 +652,6 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= @@ -861,7 +676,6 @@ golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgw golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= @@ -890,18 +704,10 @@ golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= -golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -924,30 +730,13 @@ google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0M google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= -google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= -google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE= -google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= -google.golang.org/api v0.41.0/go.mod h1:RkxM5lITDfTzmyKFPt+wGrCJbVfniCr2ool8kTBzRTU= -google.golang.org/api v0.43.0/go.mod h1:nQsDGjRXMo4lvh5hP0TKqF244gqhGcr/YSIykhUk/94= -google.golang.org/api v0.47.0/go.mod h1:Wbvgpq1HddcWVtzsVLyfLp8lDg6AA241LmgIL59tHXo= -google.golang.org/api v0.48.0/go.mod h1:71Pr1vy+TAZRPkPs/xlCf5SsU8WjuAWv1Pfjbtukyy4= -google.golang.org/api v0.50.0/go.mod h1:4bNT5pAuq5ji4SRZm+5QIkjny9JAyVD/3gaSihNefaw= -google.golang.org/api v0.51.0/go.mod h1:t4HdrdoNgyN5cbEfm7Lum0lcLDLiise1F8qDKX00sOU= -google.golang.org/api v0.54.0/go.mod h1:7C4bFFOvVDGXjfDTAsgGwDgAxRDeQ4X8NvUedIt6z3k= -google.golang.org/api v0.55.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= -google.golang.org/api v0.56.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= -google.golang.org/api v0.57.0/go.mod h1:dVPlbZyBo2/OjBpmvNdpn2GRm6rPy75jyU7bmhdrMgI= -google.golang.org/api v0.59.0/go.mod h1:sT2boj7M9YJxZzgeZqXogmhfmRWDtPzT31xkieUbuZU= -google.golang.org/api v0.61.0/go.mod h1:xQRti5UdCmoCEqFxcz93fTl338AVqDgyaDRuOZ3hg9I= -google.golang.org/api v0.62.0/go.mod h1:dKmwPCydfsad4qCH08MSdgWjfHOyfpd4VtDGgRFdavw= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.6 h1:lMO5rYAqUxkmaj76jAkRUvt5JZgFymx/+Q5Mzfivuhc= google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= -google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= @@ -978,40 +767,8 @@ google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7Fc google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201019141844-1ed22bb0c154/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210222152913-aa3ee6e6a81c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= -google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210604141403-392c879c8b08/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210608205507-b6d2f5bf0d7d/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84/go.mod h1:SzzZ/N+nwJDaO1kznhnlzqS8ocJICar6hYhVyhi++24= -google.golang.org/genproto v0.0.0-20210713002101-d411969a0d9a/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= -google.golang.org/genproto v0.0.0-20210716133855-ce7ef5c701ea/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= -google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= -google.golang.org/genproto v0.0.0-20210805201207-89edb61ffb67/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= -google.golang.org/genproto v0.0.0-20210813162853-db860fec028c/go.mod h1:cFeNkxwySK631ADgubI+/XFU/xp8FD5KIVV4rj8UC5w= -google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210831024726-fe130286e0e2/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210903162649-d08c68adba83/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210909211513-a8c4777a87af/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211008145708-270636b82663/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211028162531-8db9c33dc351/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211129164237-f09f9a12af12/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211203200212-54befc351ae9/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211206160659-862468c7d6e0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20220422154200-b37d22cd5731 h1:nquqdM9+ps0JZcIiI70+tqoaIFS5Ql4ZuK8UXnz3HfE= google.golang.org/genproto v0.0.0-20220422154200-b37d22cd5731/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= @@ -1026,26 +783,13 @@ google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKa google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= -google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= -google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= -google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.37.1/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= -google.golang.org/grpc v1.39.1/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= -google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= -google.golang.org/grpc v1.40.1/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= google.golang.org/grpc v1.41.0/go.mod h1:U3l9uK9J0sini8mHphKoXyaqDA/8VyGnDee1zzIUK6k= -google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= google.golang.org/grpc v1.46.2 h1:u+MLGgVf7vRdjEYZ8wDFhAVNmhkbJ5hmrA1LMWK1CAQ= google.golang.org/grpc v1.46.2/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -1075,7 +819,6 @@ gopkg.in/h2non/gock.v1 v1.1.2 h1:jBbHXgGBK/AoPVfJh5x4r/WxIrElvbLel8TCZkkZJoY= gopkg.in/h2non/gock.v1 v1.1.2/go.mod h1:n7UGz/ckNChHiK05rDoiC4MYSunEC/lyaUm2WWaDva0= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= -gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/tools/goctl/internal/version/version.go b/tools/goctl/internal/version/version.go index 95faebf8..10daec98 100644 --- a/tools/goctl/internal/version/version.go +++ b/tools/goctl/internal/version/version.go @@ -6,7 +6,7 @@ import ( ) // BuildVersion is the version of goctl. -const BuildVersion = "1.4.4" +const BuildVersion = "1.5.0" var tag = map[string]int{"pre-alpha": 0, "alpha": 1, "pre-bata": 2, "beta": 3, "released": 4, "": 5} diff --git a/tools/goctl/model/sql/README.MD b/tools/goctl/model/sql/README.MD index 772dda04..3f8defe5 100644 --- a/tools/goctl/model/sql/README.MD +++ b/tools/goctl/model/sql/README.MD @@ -105,7 +105,7 @@ goctl model 为go-zero下的工具模块中的组件之一,目前支持识别m func (m *defaultUserModel) FindOne(id int64) (*User, error) { userIdKey := fmt.Sprintf("%s%v", cacheUserIdPrefix, id) var resp User - err := m.QueryRow(&resp, userIdKey, func(conn sqlx.SqlConn, v interface{}) error { + err := m.QueryRow(&resp, userIdKey, func(conn sqlx.SqlConn, v any) error { query := fmt.Sprintf("select %s from %s where id = ? limit 1", userRows, m.table) return conn.QueryRow(v, query, id) }) diff --git a/tools/goctl/model/sql/gen/gen.go b/tools/goctl/model/sql/gen/gen.go index 187653b6..e839f0e3 100644 --- a/tools/goctl/model/sql/gen/gen.go +++ b/tools/goctl/model/sql/gen/gen.go @@ -197,7 +197,7 @@ func (g *defaultGenerator) createFile(modelList map[string]*codeTuple) error { return err } - err = util.With("vars").Parse(text).SaveTo(map[string]interface{}{ + err = util.With("vars").Parse(text).SaveTo(map[string]any{ "pkg": g.pkg, }, filename, false) if err != nil { diff --git a/tools/goctl/model/sql/gen/imports.go b/tools/goctl/model/sql/gen/imports.go index e17c3c84..4a5b02ab 100644 --- a/tools/goctl/model/sql/gen/imports.go +++ b/tools/goctl/model/sql/gen/imports.go @@ -13,7 +13,7 @@ func genImports(table Table, withCache, timeImport bool) (string, error) { return "", err } - buffer, err := util.With("import").Parse(text).Execute(map[string]interface{}{ + buffer, err := util.With("import").Parse(text).Execute(map[string]any{ "time": timeImport, "containsPQ": table.ContainsPQ, "data": table, diff --git a/tools/goctl/model/sql/gen/update.go b/tools/goctl/model/sql/gen/update.go index 09554aa3..98e2299c 100644 --- a/tools/goctl/model/sql/gen/update.go +++ b/tools/goctl/model/sql/gen/update.go @@ -62,7 +62,7 @@ func genUpdate(table Table, withCache, postgreSql bool) ( } output, err := util.With("update").Parse(text).Execute( - map[string]interface{}{ + map[string]any{ "withCache": withCache, "containsIndexCache": table.ContainsUniqueCacheKey, "upperStartCamelObject": camelTableName, diff --git a/tools/goctl/pkg/collection/sortedmap.go b/tools/goctl/pkg/collection/sortedmap.go index 0a51ce20..e00d1470 100644 --- a/tools/goctl/pkg/collection/sortedmap.go +++ b/tools/goctl/pkg/collection/sortedmap.go @@ -14,21 +14,21 @@ var ( ErrInvalidKVS = errors.New("the length of kv must be an even number") ) -type KV []interface{} +type KV []any type SortedMap struct { kv *list.List - keys map[interface{}]*list.Element + keys map[any]*list.Element } func New() *SortedMap { return &SortedMap{ kv: list.New(), - keys: make(map[interface{}]*list.Element), + keys: make(map[any]*list.Element), } } -func (m *SortedMap) SetExpression(expression string) (key, value interface{}, err error) { +func (m *SortedMap) SetExpression(expression string) (key, value any, err error) { idx := strings.Index(expression, "=") if idx == -1 { return "", "", ErrInvalidKVExpression @@ -53,7 +53,7 @@ func (m *SortedMap) SetExpression(expression string) (key, value interface{}, er return } -func (m *SortedMap) SetKV(key, value interface{}) { +func (m *SortedMap) SetKV(key, value any) { e, ok := m.keys[key] if !ok { e = m.kv.PushBack(KV{ @@ -78,7 +78,7 @@ func (m *SortedMap) Set(kv KV) error { return nil } -func (m *SortedMap) Get(key interface{}) (interface{}, bool) { +func (m *SortedMap) Get(key any) (any, bool) { e, ok := m.keys[key] if !ok { return nil, false @@ -86,7 +86,7 @@ func (m *SortedMap) Get(key interface{}) (interface{}, bool) { return e.Value.(KV)[1], true } -func (m *SortedMap) GetOr(key, dft interface{}) interface{} { +func (m *SortedMap) GetOr(key, dft any) any { e, ok := m.keys[key] if !ok { return dft @@ -94,7 +94,7 @@ func (m *SortedMap) GetOr(key, dft interface{}) interface{} { return e.Value.(KV)[1] } -func (m *SortedMap) GetString(key interface{}) (string, bool) { +func (m *SortedMap) GetString(key any) (string, bool) { value, ok := m.Get(key) if !ok { return "", false @@ -103,7 +103,7 @@ func (m *SortedMap) GetString(key interface{}) (string, bool) { return vs, ok } -func (m *SortedMap) GetStringOr(key interface{}, dft string) string { +func (m *SortedMap) GetStringOr(key any, dft string) string { value, ok := m.GetString(key) if !ok { return dft @@ -111,14 +111,14 @@ func (m *SortedMap) GetStringOr(key interface{}, dft string) string { return value } -func (m *SortedMap) HasKey(key interface{}) bool { +func (m *SortedMap) HasKey(key any) bool { _, ok := m.keys[key] return ok } -func (m *SortedMap) HasValue(value interface{}) bool { +func (m *SortedMap) HasValue(value any) bool { var contains bool - m.RangeIf(func(key, v interface{}) bool { + m.RangeIf(func(key, v any) bool { if value == v { contains = true return false @@ -128,8 +128,8 @@ func (m *SortedMap) HasValue(value interface{}) bool { return contains } -func (m *SortedMap) Keys() []interface{} { - keys := make([]interface{}, 0) +func (m *SortedMap) Keys() []any { + keys := make([]any, 0) next := m.kv.Front() for next != nil { keys = append(keys, next.Value.(KV)[0]) @@ -138,16 +138,16 @@ func (m *SortedMap) Keys() []interface{} { return keys } -func (m *SortedMap) Values() []interface{} { +func (m *SortedMap) Values() []any { keys := m.Keys() - values := make([]interface{}, len(keys)) + values := make([]any, len(keys)) for idx, key := range keys { values[idx] = m.keys[key].Value.(KV)[1] } return values } -func (m *SortedMap) Range(iterator func(key, value interface{})) { +func (m *SortedMap) Range(iterator func(key, value any)) { next := m.kv.Front() for next != nil { value := next.Value.(KV) @@ -156,7 +156,7 @@ func (m *SortedMap) Range(iterator func(key, value interface{})) { } } -func (m *SortedMap) RangeIf(iterator func(key, value interface{}) bool) { +func (m *SortedMap) RangeIf(iterator func(key, value any) bool) { next := m.kv.Front() for next != nil { value := next.Value.(KV) @@ -168,7 +168,7 @@ func (m *SortedMap) RangeIf(iterator func(key, value interface{}) bool) { } } -func (m *SortedMap) Remove(key interface{}) (value interface{}, ok bool) { +func (m *SortedMap) Remove(key any) (value any, ok bool) { v, ok := m.keys[key] if !ok { return nil, false @@ -181,14 +181,14 @@ func (m *SortedMap) Remove(key interface{}) (value interface{}, ok bool) { } func (m *SortedMap) Insert(sm *SortedMap) { - sm.Range(func(key, value interface{}) { + sm.Range(func(key, value any) { m.SetKV(key, value) }) } func (m *SortedMap) Copy() *SortedMap { sm := New() - m.Range(func(key, value interface{}) { + m.Range(func(key, value any) { sm.SetKV(key, value) }) return sm @@ -196,7 +196,7 @@ func (m *SortedMap) Copy() *SortedMap { func (m *SortedMap) Format() []string { format := make([]string, 0) - m.Range(func(key, value interface{}) { + m.Range(func(key, value any) { format = append(format, fmt.Sprintf("%s=%s", key, value)) }) return format diff --git a/tools/goctl/pkg/collection/sortedmap_test.go b/tools/goctl/pkg/collection/sortedmap_test.go index 788804bd..96092744 100644 --- a/tools/goctl/pkg/collection/sortedmap_test.go +++ b/tools/goctl/pkg/collection/sortedmap_test.go @@ -142,7 +142,7 @@ func Test_SortedMap(t *testing.T) { t.Run("Range", func(t *testing.T) { var keys, values []string - sm.Range(func(key, value interface{}) { + sm.Range(func(key, value any) { keys = append(keys, key.(string)) values = append(values, value.(string)) }) @@ -153,7 +153,7 @@ func Test_SortedMap(t *testing.T) { for _, key := range expected { sm.SetKV(key, key) } - sm.Range(func(key, value interface{}) { + sm.Range(func(key, value any) { keys = append(keys, key.(string)) values = append(values, value.(string)) }) @@ -164,7 +164,7 @@ func Test_SortedMap(t *testing.T) { t.Run("RangeIf", func(t *testing.T) { var keys, values []string - sm.RangeIf(func(key, value interface{}) bool { + sm.RangeIf(func(key, value any) bool { keys = append(keys, key.(string)) values = append(values, value.(string)) return true @@ -176,7 +176,7 @@ func Test_SortedMap(t *testing.T) { for _, key := range expected { sm.SetKV(key, key) } - sm.RangeIf(func(key, value interface{}) bool { + sm.RangeIf(func(key, value any) bool { keys = append(keys, key.(string)) values = append(values, value.(string)) if key.(string) == "foo1" { diff --git a/tools/goctl/pkg/env/env.go b/tools/goctl/pkg/env/env.go index 99fc11d9..173c8fbd 100644 --- a/tools/goctl/pkg/env/env.go +++ b/tools/goctl/pkg/env/env.go @@ -122,7 +122,7 @@ func WriteEnv(kv []string) error { return err } } - data.RangeIf(func(key, value interface{}) bool { + data.RangeIf(func(key, value any) bool { switch key.(string) { case GoctlHome, GoctlCache: path := value.(string) diff --git a/tools/goctl/rpc/generator/gencall.go b/tools/goctl/rpc/generator/gencall.go index 24331bd2..6d3d38b2 100644 --- a/tools/goctl/rpc/generator/gencall.go +++ b/tools/goctl/rpc/generator/gencall.go @@ -96,7 +96,7 @@ func (g *Generator) genCallGroup(ctx DirContext, proto parser.Proto, cfg *conf.C aliasKeys := alias.KeysStr() sort.Strings(aliasKeys) - if err = util.With("shared").GoFmt(true).Parse(text).SaveTo(map[string]interface{}{ + if err = util.With("shared").GoFmt(true).Parse(text).SaveTo(map[string]any{ "name": callFilename, "alias": strings.Join(aliasKeys, pathx.NL), "head": head, @@ -159,7 +159,7 @@ func (g *Generator) genCallInCompatibility(ctx DirContext, proto parser.Proto, } aliasKeys := alias.KeysStr() sort.Strings(aliasKeys) - return util.With("shared").GoFmt(true).Parse(text).SaveTo(map[string]interface{}{ + return util.With("shared").GoFmt(true).Parse(text).SaveTo(map[string]any{ "name": callFilename, "alias": strings.Join(aliasKeys, pathx.NL), "head": head, @@ -211,7 +211,7 @@ func (g *Generator) genFunction(goPackage string, service parser.Service, streamServer = fmt.Sprintf("%s_%s%s", parser.CamelCase(service.Name), parser.CamelCase(rpc.Name), "Client") } - buffer, err := util.With("sharedFn").Parse(text).Execute(map[string]interface{}{ + buffer, err := util.With("sharedFn").Parse(text).Execute(map[string]any{ "serviceName": stringx.From(service.Name).ToCamel(), "rpcServiceName": parser.CamelCase(service.Name), "method": parser.CamelCase(rpc.Name), @@ -254,7 +254,7 @@ func (g *Generator) getInterfaceFuncs(goPackage string, service parser.Service, parser.CamelCase(rpc.Name), "Client") } buffer, err := util.With("interfaceFn").Parse(text).Execute( - map[string]interface{}{ + map[string]any{ "hasComment": len(comment) > 0, "comment": comment, "method": parser.CamelCase(rpc.Name), diff --git a/tools/goctl/rpc/generator/genetc.go b/tools/goctl/rpc/generator/genetc.go index a5d92e0c..8729e76f 100644 --- a/tools/goctl/rpc/generator/genetc.go +++ b/tools/goctl/rpc/generator/genetc.go @@ -33,7 +33,7 @@ func (g *Generator) GenEtc(ctx DirContext, _ parser.Proto, cfg *conf.Config) err return err } - return util.With("etc").Parse(text).SaveTo(map[string]interface{}{ + return util.With("etc").Parse(text).SaveTo(map[string]any{ "serviceName": strings.ToLower(stringx.From(ctx.GetServiceName().Source()).ToCamel()), }, fileName, false) } diff --git a/tools/goctl/rpc/generator/genlogic.go b/tools/goctl/rpc/generator/genlogic.go index 293779e7..43acd0ea 100644 --- a/tools/goctl/rpc/generator/genlogic.go +++ b/tools/goctl/rpc/generator/genlogic.go @@ -60,7 +60,7 @@ func (g *Generator) genLogicInCompatibility(ctx DirContext, proto parser.Proto, if err != nil { return err } - err = util.With("logic").GoFmt(true).Parse(text).SaveTo(map[string]interface{}{ + err = util.With("logic").GoFmt(true).Parse(text).SaveTo(map[string]any{ "logicName": fmt.Sprintf("%sLogic", stringx.From(rpc.Name).ToCamel()), "functions": functions, "packageName": "logic", @@ -114,7 +114,7 @@ func (g *Generator) genLogicGroup(ctx DirContext, proto parser.Proto, cfg *conf. return err } - if err = util.With("logic").GoFmt(true).Parse(text).SaveTo(map[string]interface{}{ + if err = util.With("logic").GoFmt(true).Parse(text).SaveTo(map[string]any{ "logicName": logicName, "functions": functions, "packageName": packageName, @@ -139,7 +139,7 @@ func (g *Generator) genLogicFunction(serviceName, goPackage, logicName string, comment := parser.GetComment(rpc.Doc()) streamServer := fmt.Sprintf("%s.%s_%s%s", goPackage, parser.CamelCase(serviceName), parser.CamelCase(rpc.Name), "Server") - buffer, err := util.With("fun").Parse(text).Execute(map[string]interface{}{ + buffer, err := util.With("fun").Parse(text).Execute(map[string]any{ "logicName": logicName, "method": parser.CamelCase(rpc.Name), "hasReq": !rpc.StreamsRequest, diff --git a/tools/goctl/rpc/generator/genmain.go b/tools/goctl/rpc/generator/genmain.go index 8bbde495..02381538 100644 --- a/tools/goctl/rpc/generator/genmain.go +++ b/tools/goctl/rpc/generator/genmain.go @@ -73,7 +73,7 @@ func (g *Generator) GenMain(ctx DirContext, proto parser.Proto, cfg *conf.Config return err } - return util.With("main").GoFmt(true).Parse(text).SaveTo(map[string]interface{}{ + return util.With("main").GoFmt(true).Parse(text).SaveTo(map[string]any{ "serviceName": etcFileName, "imports": strings.Join(imports, pathx.NL), "pkg": proto.PbPackage, diff --git a/tools/goctl/rpc/generator/genserver.go b/tools/goctl/rpc/generator/genserver.go index 675d78ce..04c816bf 100644 --- a/tools/goctl/rpc/generator/genserver.go +++ b/tools/goctl/rpc/generator/genserver.go @@ -89,7 +89,7 @@ func (g *Generator) genServerGroup(ctx DirContext, proto parser.Proto, cfg *conf } } - if err = util.With("server").GoFmt(true).Parse(text).SaveTo(map[string]interface{}{ + if err = util.With("server").GoFmt(true).Parse(text).SaveTo(map[string]any{ "head": head, "unimplementedServer": fmt.Sprintf("%s.Unimplemented%sServer", proto.PbPackage, stringx.From(service.Name).ToCamel()), @@ -140,7 +140,7 @@ func (g *Generator) genServerInCompatibility(ctx DirContext, proto parser.Proto, } } - return util.With("server").GoFmt(true).Parse(text).SaveTo(map[string]interface{}{ + return util.With("server").GoFmt(true).Parse(text).SaveTo(map[string]any{ "head": head, "unimplementedServer": fmt.Sprintf("%s.Unimplemented%sServer", proto.PbPackage, stringx.From(service.Name).ToCamel()), @@ -175,7 +175,7 @@ func (g *Generator) genFunctions(goPackage string, service parser.Service, multi comment := parser.GetComment(rpc.Doc()) streamServer := fmt.Sprintf("%s.%s_%s%s", goPackage, parser.CamelCase(service.Name), parser.CamelCase(rpc.Name), "Server") - buffer, err := util.With("func").Parse(text).Execute(map[string]interface{}{ + buffer, err := util.With("func").Parse(text).Execute(map[string]any{ "server": stringx.From(service.Name).ToCamel(), "logicName": logicName, "method": parser.CamelCase(rpc.Name), diff --git a/tools/goctl/rpc/generator/gensvc.go b/tools/goctl/rpc/generator/gensvc.go index fcad078a..533100cb 100644 --- a/tools/goctl/rpc/generator/gensvc.go +++ b/tools/goctl/rpc/generator/gensvc.go @@ -30,7 +30,7 @@ func (g *Generator) GenSvc(ctx DirContext, _ parser.Proto, cfg *conf.Config) err return err } - return util.With("svc").GoFmt(true).Parse(text).SaveTo(map[string]interface{}{ + return util.With("svc").GoFmt(true).Parse(text).SaveTo(map[string]any{ "imports": fmt.Sprintf(`"%v"`, ctx.GetConfig().Package), }, fileName, false) } diff --git a/tools/goctl/tproxy.yaml b/tools/goctl/tproxy.yaml deleted file mode 100644 index a9d96307..00000000 --- a/tools/goctl/tproxy.yaml +++ /dev/null @@ -1,108 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: tproxy - namespace: adhoc - labels: - app: tproxy -spec: - replicas: 3 - revisionHistoryLimit: 5 - selector: - matchLabels: - app: tproxy - template: - metadata: - labels: - app: tproxy - spec: - containers: - - name: tproxy - image: tproxy:v1 - ports: - - containerPort: 8888 - readinessProbe: - tcpSocket: - port: 8888 - initialDelaySeconds: 5 - periodSeconds: 10 - livenessProbe: - tcpSocket: - port: 8888 - initialDelaySeconds: 15 - periodSeconds: 20 - resources: - requests: - cpu: 500m - memory: 512Mi - limits: - cpu: 1000m - memory: 1024Mi - volumeMounts: - - name: timezone - mountPath: /etc/localtime - volumes: - - name: timezone - hostPath: - path: /usr/share/zoneinfo/Asia/Shanghai - ---- - -apiVersion: v1 -kind: Service -metadata: - name: tproxy-svc - namespace: adhoc -spec: - ports: - - nodePort: 30001 - port: 8888 - protocol: TCP - targetPort: 8888 - type: NodePort - selector: - app: tproxy - ---- - -apiVersion: autoscaling/v2beta1 -kind: HorizontalPodAutoscaler -metadata: - name: tproxy-hpa-c - namespace: adhoc - labels: - app: tproxy-hpa-c -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment - name: tproxy - minReplicas: 3 - maxReplicas: 10 - metrics: - - type: Resource - resource: - name: cpu - targetAverageUtilization: 80 - ---- - -apiVersion: autoscaling/v2beta1 -kind: HorizontalPodAutoscaler -metadata: - name: tproxy-hpa-m - namespace: adhoc - labels: - app: tproxy-hpa-m -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment - name: tproxy - minReplicas: 3 - maxReplicas: 10 - metrics: - - type: Resource - resource: - name: memory - targetAverageUtilization: 80 diff --git a/tools/goctl/util/console/console.go b/tools/goctl/util/console/console.go index 87c8bdba..4919bfe0 100644 --- a/tools/goctl/util/console/console.go +++ b/tools/goctl/util/console/console.go @@ -14,12 +14,12 @@ type ( // by default, it implemented the colorConsole to provide the colorful output to the console // and the ideaConsole to output with prefix for the plugin of intellij Console interface { - Success(format string, a ...interface{}) - Info(format string, a ...interface{}) - Debug(format string, a ...interface{}) - Warning(format string, a ...interface{}) - Error(format string, a ...interface{}) - Fatalln(format string, a ...interface{}) + Success(format string, a ...any) + Info(format string, a ...any) + Debug(format string, a ...any) + Warning(format string, a ...any) + Error(format string, a ...any) + Fatalln(format string, a ...any) MarkDone() Must(err error) } @@ -51,7 +51,7 @@ func NewColorConsole(enable ...bool) Console { } } -func (c *colorConsole) Info(format string, a ...interface{}) { +func (c *colorConsole) Info(format string, a ...any) { if !c.enable { return } @@ -59,7 +59,7 @@ func (c *colorConsole) Info(format string, a ...interface{}) { fmt.Println(msg) } -func (c *colorConsole) Debug(format string, a ...interface{}) { +func (c *colorConsole) Debug(format string, a ...any) { if !c.enable { return } @@ -67,7 +67,7 @@ func (c *colorConsole) Debug(format string, a ...interface{}) { println(aurora.BrightCyan(msg)) } -func (c *colorConsole) Success(format string, a ...interface{}) { +func (c *colorConsole) Success(format string, a ...any) { if !c.enable { return } @@ -75,7 +75,7 @@ func (c *colorConsole) Success(format string, a ...interface{}) { println(aurora.BrightGreen(msg)) } -func (c *colorConsole) Warning(format string, a ...interface{}) { +func (c *colorConsole) Warning(format string, a ...any) { if !c.enable { return } @@ -83,7 +83,7 @@ func (c *colorConsole) Warning(format string, a ...interface{}) { println(aurora.BrightYellow(msg)) } -func (c *colorConsole) Error(format string, a ...interface{}) { +func (c *colorConsole) Error(format string, a ...any) { if !c.enable { return } @@ -91,7 +91,7 @@ func (c *colorConsole) Error(format string, a ...interface{}) { println(aurora.BrightRed(msg)) } -func (c *colorConsole) Fatalln(format string, a ...interface{}) { +func (c *colorConsole) Fatalln(format string, a ...any) { if !c.enable { return } @@ -120,7 +120,7 @@ func NewIdeaConsole() Console { return &ideaConsole{} } -func (i *ideaConsole) Info(format string, a ...interface{}) { +func (i *ideaConsole) Info(format string, a ...any) { msg := fmt.Sprintf(format, a...) fmt.Println(msg) } diff --git a/tools/goctl/util/head.go b/tools/goctl/util/head.go index 017e344b..6e76b12e 100644 --- a/tools/goctl/util/head.go +++ b/tools/goctl/util/head.go @@ -10,7 +10,7 @@ const ( // GetHead returns a code head string with source filename func GetHead(source string) string { - buffer, _ := With("head").Parse(headTemplate).Execute(map[string]interface{}{ + buffer, _ := With("head").Parse(headTemplate).Execute(map[string]any{ "source": source, }) return buffer.String() diff --git a/tools/goctl/util/templatex.go b/tools/goctl/util/templatex.go index 5d35f6a6..0985fb25 100644 --- a/tools/goctl/util/templatex.go +++ b/tools/goctl/util/templatex.go @@ -39,7 +39,7 @@ func (t *DefaultTemplate) GoFmt(format bool) *DefaultTemplate { } // SaveTo writes the codes to the target path -func (t *DefaultTemplate) SaveTo(data interface{}, path string, forceUpdate bool) error { +func (t *DefaultTemplate) SaveTo(data any, path string, forceUpdate bool) error { if pathx.FileExists(path) && !forceUpdate { return nil } @@ -53,7 +53,7 @@ func (t *DefaultTemplate) SaveTo(data interface{}, path string, forceUpdate bool } // Execute returns the codes after the template executed -func (t *DefaultTemplate) Execute(data interface{}) (*bytes.Buffer, error) { +func (t *DefaultTemplate) Execute(data any) (*bytes.Buffer, error) { tem, err := template.New(t.name).Parse(t.text) if err != nil { return nil, errorx.Wrap(err, "template parse error:", t.text) diff --git a/zrpc/client_test.go b/zrpc/client_test.go index 3f15ae54..368ca2ee 100644 --- a/zrpc/client_test.go +++ b/zrpc/client_test.go @@ -85,7 +85,7 @@ func TestDepositServer_Deposit(t *testing.T) { }, }, WithDialOption(grpc.WithContextDialer(dialer())), - WithUnaryClientInterceptor(func(ctx context.Context, method string, req, reply interface{}, + WithUnaryClientInterceptor(func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { return invoker(ctx, method, req, reply, cc, opts...) }), @@ -106,7 +106,7 @@ func TestDepositServer_Deposit(t *testing.T) { }, }, WithDialOption(grpc.WithContextDialer(dialer())), - WithUnaryClientInterceptor(func(ctx context.Context, method string, req, reply interface{}, + WithUnaryClientInterceptor(func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { return invoker(ctx, method, req, reply, cc, opts...) }), @@ -127,7 +127,7 @@ func TestDepositServer_Deposit(t *testing.T) { }, WithDialOption(grpc.WithTransportCredentials(insecure.NewCredentials())), WithDialOption(grpc.WithContextDialer(dialer())), - WithUnaryClientInterceptor(func(ctx context.Context, method string, req, reply interface{}, + WithUnaryClientInterceptor(func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { return invoker(ctx, method, req, reply, cc, opts...) }), @@ -135,7 +135,7 @@ func TestDepositServer_Deposit(t *testing.T) { targetClient, err := NewClientWithTarget("foo", WithDialOption(grpc.WithTransportCredentials(insecure.NewCredentials())), WithDialOption(grpc.WithContextDialer(dialer())), WithUnaryClientInterceptor( - func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, + func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { return invoker(ctx, method, req, reply, cc, opts...) }), WithTimeout(1000*time.Millisecond)) @@ -188,7 +188,7 @@ func TestNewClientWithError(t *testing.T) { }, WithDialOption(grpc.WithTransportCredentials(insecure.NewCredentials())), WithDialOption(grpc.WithContextDialer(dialer())), - WithUnaryClientInterceptor(func(ctx context.Context, method string, req, reply interface{}, + WithUnaryClientInterceptor(func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { return invoker(ctx, method, req, reply, cc, opts...) }), @@ -207,7 +207,7 @@ func TestNewClientWithError(t *testing.T) { }, WithDialOption(grpc.WithTransportCredentials(insecure.NewCredentials())), WithDialOption(grpc.WithContextDialer(dialer())), - WithUnaryClientInterceptor(func(ctx context.Context, method string, req, reply interface{}, + WithUnaryClientInterceptor(func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { return invoker(ctx, method, req, reply, cc, opts...) }), diff --git a/zrpc/internal/auth/auth.go b/zrpc/internal/auth/auth.go index 2770fcf5..3b3a9e4d 100644 --- a/zrpc/internal/auth/auth.go +++ b/zrpc/internal/auth/auth.go @@ -57,7 +57,7 @@ func (a *Authenticator) Authenticate(ctx context.Context) error { } func (a *Authenticator) validate(app, token string) error { - expect, err := a.cache.Take(app, func() (interface{}, error) { + expect, err := a.cache.Take(app, func() (any, error) { return a.store.Hget(a.key, app) }) if err != nil { diff --git a/zrpc/internal/balancer/p2c/p2c_test.go b/zrpc/internal/balancer/p2c/p2c_test.go index 6553fe43..1dab287c 100644 --- a/zrpc/internal/balancer/p2c/p2c_test.go +++ b/zrpc/internal/balancer/p2c/p2c_test.go @@ -110,7 +110,7 @@ func TestP2cPicker_Pick(t *testing.T) { } wg.Wait() - dist := make(map[interface{}]int) + dist := make(map[any]int) conns := picker.(*p2cPicker).conns for _, conn := range conns { dist[conn.addr.Addr] = int(conn.requests) diff --git a/zrpc/internal/client_test.go b/zrpc/internal/client_test.go index 969d6924..6c45e2f2 100644 --- a/zrpc/internal/client_test.go +++ b/zrpc/internal/client_test.go @@ -54,7 +54,7 @@ func TestWithTransportCredentials(t *testing.T) { func TestWithUnaryClientInterceptor(t *testing.T) { var options ClientOptions - opt := WithUnaryClientInterceptor(func(ctx context.Context, method string, req, reply interface{}, + opt := WithUnaryClientInterceptor(func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { return nil }) diff --git a/zrpc/internal/clientinterceptors/breakerinterceptor.go b/zrpc/internal/clientinterceptors/breakerinterceptor.go index 05adc8e8..c4231760 100644 --- a/zrpc/internal/clientinterceptors/breakerinterceptor.go +++ b/zrpc/internal/clientinterceptors/breakerinterceptor.go @@ -10,7 +10,7 @@ import ( ) // BreakerInterceptor is an interceptor that acts as a circuit breaker. -func BreakerInterceptor(ctx context.Context, method string, req, reply interface{}, +func BreakerInterceptor(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { breakerName := path.Join(cc.Target(), method) return breaker.DoWithAcceptable(breakerName, func() error { diff --git a/zrpc/internal/clientinterceptors/breakerinterceptor_test.go b/zrpc/internal/clientinterceptors/breakerinterceptor_test.go index 5c535011..3ec8ba1a 100644 --- a/zrpc/internal/clientinterceptors/breakerinterceptor_test.go +++ b/zrpc/internal/clientinterceptors/breakerinterceptor_test.go @@ -71,7 +71,7 @@ func TestBreakerInterceptor(t *testing.T) { t.Run(test.name, func(t *testing.T) { cc := new(grpc.ClientConn) err := BreakerInterceptor(context.Background(), "/foo", nil, nil, cc, - func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, + func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, opts ...grpc.CallOption) error { return test.err }) diff --git a/zrpc/internal/clientinterceptors/durationinterceptor.go b/zrpc/internal/clientinterceptors/durationinterceptor.go index eac73af5..651c9595 100644 --- a/zrpc/internal/clientinterceptors/durationinterceptor.go +++ b/zrpc/internal/clientinterceptors/durationinterceptor.go @@ -21,7 +21,7 @@ var ( ) // DurationInterceptor is an interceptor that logs the processing time. -func DurationInterceptor(ctx context.Context, method string, req, reply interface{}, +func DurationInterceptor(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { serverName := path.Join(cc.Target(), method) start := timex.Now() diff --git a/zrpc/internal/clientinterceptors/durationinterceptor_test.go b/zrpc/internal/clientinterceptors/durationinterceptor_test.go index 844a7a6d..a851fde3 100644 --- a/zrpc/internal/clientinterceptors/durationinterceptor_test.go +++ b/zrpc/internal/clientinterceptors/durationinterceptor_test.go @@ -29,7 +29,7 @@ func TestDurationInterceptor(t *testing.T) { t.Run(test.name, func(t *testing.T) { cc := new(grpc.ClientConn) err := DurationInterceptor(context.Background(), "/foo", nil, nil, cc, - func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, + func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, opts ...grpc.CallOption) error { return test.err }) diff --git a/zrpc/internal/clientinterceptors/prometheusinterceptor.go b/zrpc/internal/clientinterceptors/prometheusinterceptor.go index 7b50144a..c682937b 100644 --- a/zrpc/internal/clientinterceptors/prometheusinterceptor.go +++ b/zrpc/internal/clientinterceptors/prometheusinterceptor.go @@ -33,7 +33,7 @@ var ( ) // PrometheusInterceptor is an interceptor that reports to prometheus server. -func PrometheusInterceptor(ctx context.Context, method string, req, reply interface{}, +func PrometheusInterceptor(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { startTime := timex.Now() err := invoker(ctx, method, req, reply, cc, opts...) diff --git a/zrpc/internal/clientinterceptors/prometheusinterceptor_test.go b/zrpc/internal/clientinterceptors/prometheusinterceptor_test.go index d2564ae7..c8d34633 100644 --- a/zrpc/internal/clientinterceptors/prometheusinterceptor_test.go +++ b/zrpc/internal/clientinterceptors/prometheusinterceptor_test.go @@ -40,7 +40,7 @@ func TestPromMetricInterceptor(t *testing.T) { } cc := new(grpc.ClientConn) err := PrometheusInterceptor(context.Background(), "/foo", nil, nil, cc, - func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, + func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, opts ...grpc.CallOption) error { return test.err }) diff --git a/zrpc/internal/clientinterceptors/timeoutinterceptor.go b/zrpc/internal/clientinterceptors/timeoutinterceptor.go index d6fc9c19..20111fc1 100644 --- a/zrpc/internal/clientinterceptors/timeoutinterceptor.go +++ b/zrpc/internal/clientinterceptors/timeoutinterceptor.go @@ -9,7 +9,7 @@ import ( // TimeoutInterceptor is an interceptor that controls timeout. func TimeoutInterceptor(timeout time.Duration) grpc.UnaryClientInterceptor { - return func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, + return func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { if timeout <= 0 { return invoker(ctx, method, req, reply, cc, opts...) diff --git a/zrpc/internal/clientinterceptors/timeoutinterceptor_test.go b/zrpc/internal/clientinterceptors/timeoutinterceptor_test.go index d45a8511..67b5ab05 100644 --- a/zrpc/internal/clientinterceptors/timeoutinterceptor_test.go +++ b/zrpc/internal/clientinterceptors/timeoutinterceptor_test.go @@ -18,7 +18,7 @@ func TestTimeoutInterceptor(t *testing.T) { interceptor := TimeoutInterceptor(timeout) cc := new(grpc.ClientConn) err := interceptor(context.Background(), "/foo", nil, nil, cc, - func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, + func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, opts ...grpc.CallOption) error { return nil }, @@ -37,7 +37,7 @@ func TestTimeoutInterceptor_timeout(t *testing.T) { wg.Add(1) cc := new(grpc.ClientConn) err := interceptor(ctx, "/foo", nil, nil, cc, - func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, + func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, opts ...grpc.CallOption) error { defer wg.Done() tm, ok := ctx.Deadline() @@ -57,7 +57,7 @@ func TestTimeoutInterceptor_panic(t *testing.T) { cc := new(grpc.ClientConn) assert.Panics(t, func() { _ = interceptor(context.Background(), "/foo", nil, nil, cc, - func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, + func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, opts ...grpc.CallOption) error { panic("any") }, diff --git a/zrpc/internal/clientinterceptors/tracinginterceptor.go b/zrpc/internal/clientinterceptors/tracinginterceptor.go index e9cbc6ef..006c4691 100644 --- a/zrpc/internal/clientinterceptors/tracinginterceptor.go +++ b/zrpc/internal/clientinterceptors/tracinginterceptor.go @@ -20,7 +20,7 @@ const ( ) // UnaryTracingInterceptor returns a grpc.UnaryClientInterceptor for opentelemetry. -func UnaryTracingInterceptor(ctx context.Context, method string, req, reply interface{}, +func UnaryTracingInterceptor(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { ctx, span := startSpan(ctx, method, cc.Target()) defer span.End() @@ -118,7 +118,7 @@ func (w *clientStream) Header() (metadata.MD, error) { return md, err } -func (w *clientStream) RecvMsg(m interface{}) error { +func (w *clientStream) RecvMsg(m any) error { err := w.ClientStream.RecvMsg(m) if err == nil && !w.desc.ServerStreams { w.sendStreamEvent(receiveEndEvent, nil) @@ -134,7 +134,7 @@ func (w *clientStream) RecvMsg(m interface{}) error { return err } -func (w *clientStream) SendMsg(m interface{}) error { +func (w *clientStream) SendMsg(m any) error { err := w.ClientStream.SendMsg(m) w.sentMessageID++ ztrace.MessageSent.Event(w.Context(), w.sentMessageID, m) diff --git a/zrpc/internal/clientinterceptors/tracinginterceptor_test.go b/zrpc/internal/clientinterceptors/tracinginterceptor_test.go index 963013e2..c5a7b0a3 100644 --- a/zrpc/internal/clientinterceptors/tracinginterceptor_test.go +++ b/zrpc/internal/clientinterceptors/tracinginterceptor_test.go @@ -28,7 +28,7 @@ func TestOpenTracingInterceptor(t *testing.T) { cc := new(grpc.ClientConn) ctx := metadata.NewOutgoingContext(context.Background(), metadata.MD{}) err := UnaryTracingInterceptor(ctx, "/ListUser", nil, nil, cc, - func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, + func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, opts ...grpc.CallOption) error { return nil }) @@ -41,7 +41,7 @@ func TestUnaryTracingInterceptor(t *testing.T) { wg.Add(1) cc := new(grpc.ClientConn) err := UnaryTracingInterceptor(context.Background(), "/foo", nil, nil, cc, - func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, + func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, opts ...grpc.CallOption) error { defer wg.Done() atomic.AddInt32(&run, 1) @@ -58,7 +58,7 @@ func TestUnaryTracingInterceptor_WithError(t *testing.T) { wg.Add(1) cc := new(grpc.ClientConn) err := UnaryTracingInterceptor(context.Background(), "/foo", nil, nil, cc, - func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, + func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, opts ...grpc.CallOption) error { defer wg.Done() atomic.AddInt32(&run, 1) @@ -195,7 +195,7 @@ func TestUnaryTracingInterceptor_GrpcFormat(t *testing.T) { wg.Add(1) cc := new(grpc.ClientConn) err := UnaryTracingInterceptor(context.Background(), "/foo", nil, nil, cc, - func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, + func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, opts ...grpc.CallOption) error { defer wg.Done() atomic.AddInt32(&run, 1) @@ -339,10 +339,10 @@ func (m *mockedClientStream) Context() context.Context { return context.Background() } -func (m *mockedClientStream) SendMsg(v interface{}) error { +func (m *mockedClientStream) SendMsg(v any) error { return m.err } -func (m *mockedClientStream) RecvMsg(v interface{}) error { +func (m *mockedClientStream) RecvMsg(v any) error { return m.err } diff --git a/zrpc/internal/mock/deposit.pb.go b/zrpc/internal/mock/deposit.pb.go index 6ebe3aab..64e05339 100644 --- a/zrpc/internal/mock/deposit.pb.go +++ b/zrpc/internal/mock/deposit.pb.go @@ -150,7 +150,7 @@ func file_deposit_proto_rawDescGZIP() []byte { var ( file_deposit_proto_msgTypes = make([]protoimpl.MessageInfo, 2) - file_deposit_proto_goTypes = []interface{}{ + file_deposit_proto_goTypes = []any{ (*DepositRequest)(nil), // 0: mock.DepositRequest (*DepositResponse)(nil), // 1: mock.DepositResponse } @@ -172,7 +172,7 @@ func file_deposit_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_deposit_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_deposit_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*DepositRequest); i { case 0: return &v.state @@ -184,7 +184,7 @@ func file_deposit_proto_init() { return nil } } - file_deposit_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_deposit_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*DepositResponse); i { case 0: return &v.state @@ -267,7 +267,7 @@ func RegisterDepositServiceServer(s *grpc.Server, srv DepositServiceServer) { s.RegisterService(&_DepositService_serviceDesc, srv) } -func _DepositService_Deposit_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _DepositService_Deposit_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(DepositRequest) if err := dec(in); err != nil { return nil, err @@ -279,7 +279,7 @@ func _DepositService_Deposit_Handler(srv interface{}, ctx context.Context, dec f Server: srv, FullMethod: "/mock.DepositService/Deposit", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(DepositServiceServer).Deposit(ctx, req.(*DepositRequest)) } return interceptor(ctx, in, info, handler) diff --git a/zrpc/internal/rpclogger.go b/zrpc/internal/rpclogger.go index e3c3148c..d20887a2 100644 --- a/zrpc/internal/rpclogger.go +++ b/zrpc/internal/rpclogger.go @@ -16,47 +16,47 @@ func init() { } // Error logs the given args into error log. -func (l *Logger) Error(args ...interface{}) { +func (l *Logger) Error(args ...any) { logx.Error(args...) } // Errorf logs the given args with format into error log. -func (l *Logger) Errorf(format string, args ...interface{}) { +func (l *Logger) Errorf(format string, args ...any) { logx.Errorf(format, args...) } // Errorln logs the given args into error log with newline. -func (l *Logger) Errorln(args ...interface{}) { +func (l *Logger) Errorln(args ...any) { logx.Error(args...) } // Fatal logs the given args into error log. -func (l *Logger) Fatal(args ...interface{}) { +func (l *Logger) Fatal(args ...any) { logx.Error(args...) } // Fatalf logs the given args with format into error log. -func (l *Logger) Fatalf(format string, args ...interface{}) { +func (l *Logger) Fatalf(format string, args ...any) { logx.Errorf(format, args...) } // Fatalln logs args into error log with newline. -func (l *Logger) Fatalln(args ...interface{}) { +func (l *Logger) Fatalln(args ...any) { logx.Error(args...) } // Info ignores the grpc info logs. -func (l *Logger) Info(args ...interface{}) { +func (l *Logger) Info(args ...any) { // ignore builtin grpc info } // Infoln ignores the grpc info logs. -func (l *Logger) Infoln(args ...interface{}) { +func (l *Logger) Infoln(args ...any) { // ignore builtin grpc info } // Infof ignores the grpc info logs. -func (l *Logger) Infof(format string, args ...interface{}) { +func (l *Logger) Infof(format string, args ...any) { // ignore builtin grpc info } @@ -66,16 +66,16 @@ func (l *Logger) V(v int) bool { } // Warning ignores the grpc warning logs. -func (l *Logger) Warning(args ...interface{}) { +func (l *Logger) Warning(args ...any) { // ignore builtin grpc warning } // Warningf ignores the grpc warning logs. -func (l *Logger) Warningf(format string, args ...interface{}) { +func (l *Logger) Warningf(format string, args ...any) { // ignore builtin grpc warning } // Warningln ignores the grpc warning logs. -func (l *Logger) Warningln(args ...interface{}) { +func (l *Logger) Warningln(args ...any) { // ignore builtin grpc warning } diff --git a/zrpc/internal/server_test.go b/zrpc/internal/server_test.go index 3a11254d..fa48f7b4 100644 --- a/zrpc/internal/server_test.go +++ b/zrpc/internal/server_test.go @@ -23,7 +23,7 @@ func TestBaseRpcServer_AddStreamInterceptors(t *testing.T) { server := newBaseRpcServer("foo", &rpcServerOptions{metrics: metrics}) server.SetName("bar") var vals []int - f := func(_ interface{}, _ grpc.ServerStream, _ *grpc.StreamServerInfo, _ grpc.StreamHandler) error { + f := func(_ any, _ grpc.ServerStream, _ *grpc.StreamServerInfo, _ grpc.StreamHandler) error { vals = append(vals, 1) return nil } @@ -39,8 +39,8 @@ func TestBaseRpcServer_AddUnaryInterceptors(t *testing.T) { server := newBaseRpcServer("foo", &rpcServerOptions{metrics: metrics}) server.SetName("bar") var vals []int - f := func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) ( - resp interface{}, err error) { + f := func(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) ( + resp any, err error) { vals = append(vals, 1) return nil, nil } diff --git a/zrpc/internal/serverinterceptors/authinterceptor.go b/zrpc/internal/serverinterceptors/authinterceptor.go index 3032ee0c..7c2a1a9e 100644 --- a/zrpc/internal/serverinterceptors/authinterceptor.go +++ b/zrpc/internal/serverinterceptors/authinterceptor.go @@ -9,7 +9,7 @@ import ( // StreamAuthorizeInterceptor returns a func that uses given authenticator in processing stream requests. func StreamAuthorizeInterceptor(authenticator *auth.Authenticator) grpc.StreamServerInterceptor { - return func(svr interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, + return func(svr any, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { if err := authenticator.Authenticate(stream.Context()); err != nil { return err @@ -21,8 +21,8 @@ func StreamAuthorizeInterceptor(authenticator *auth.Authenticator) grpc.StreamSe // UnaryAuthorizeInterceptor returns a func that uses given authenticator in processing unary requests. func UnaryAuthorizeInterceptor(authenticator *auth.Authenticator) grpc.UnaryServerInterceptor { - return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, - handler grpc.UnaryHandler) (interface{}, error) { + return func(ctx context.Context, req any, info *grpc.UnaryServerInfo, + handler grpc.UnaryHandler) (any, error) { if err := authenticator.Authenticate(ctx); err != nil { return nil, err } diff --git a/zrpc/internal/serverinterceptors/authinterceptor_test.go b/zrpc/internal/serverinterceptors/authinterceptor_test.go index 7d7d44b8..587c3d7f 100644 --- a/zrpc/internal/serverinterceptors/authinterceptor_test.go +++ b/zrpc/internal/serverinterceptors/authinterceptor_test.go @@ -65,7 +65,7 @@ func TestStreamAuthorizeInterceptor(t *testing.T) { }) ctx := metadata.NewIncomingContext(context.Background(), md) stream := mockedStream{ctx: ctx} - err = interceptor(nil, stream, nil, func(_ interface{}, _ grpc.ServerStream) error { + err = interceptor(nil, stream, nil, func(_ any, _ grpc.ServerStream) error { return nil }) if test.hasError { @@ -131,7 +131,7 @@ func TestUnaryAuthorizeInterceptor(t *testing.T) { }) ctx := metadata.NewIncomingContext(context.Background(), md) _, err = interceptor(ctx, nil, nil, - func(ctx context.Context, req interface{}) (interface{}, error) { + func(ctx context.Context, req any) (any, error) { return nil, nil }) if test.hasError { @@ -141,7 +141,7 @@ func TestUnaryAuthorizeInterceptor(t *testing.T) { } if test.strict { _, err = interceptor(context.Background(), nil, nil, - func(ctx context.Context, req interface{}) (interface{}, error) { + func(ctx context.Context, req any) (any, error) { return nil, nil }) assert.NotNil(t, err) @@ -149,7 +149,7 @@ func TestUnaryAuthorizeInterceptor(t *testing.T) { var md metadata.MD ctx := metadata.NewIncomingContext(context.Background(), md) _, err = interceptor(ctx, nil, nil, - func(ctx context.Context, req interface{}) (interface{}, error) { + func(ctx context.Context, req any) (any, error) { return nil, nil }) assert.NotNil(t, err) @@ -160,7 +160,7 @@ func TestUnaryAuthorizeInterceptor(t *testing.T) { }) ctx = metadata.NewIncomingContext(context.Background(), md) _, err = interceptor(ctx, nil, nil, - func(ctx context.Context, req interface{}) (interface{}, error) { + func(ctx context.Context, req any) (any, error) { return nil, nil }) assert.NotNil(t, err) @@ -188,10 +188,10 @@ func (m mockedStream) Context() context.Context { return m.ctx } -func (m mockedStream) SendMsg(v interface{}) error { +func (m mockedStream) SendMsg(v any) error { return nil } -func (m mockedStream) RecvMsg(v interface{}) error { +func (m mockedStream) RecvMsg(v any) error { return nil } diff --git a/zrpc/internal/serverinterceptors/breakerinterceptor.go b/zrpc/internal/serverinterceptors/breakerinterceptor.go index 8e0f60b1..0298658f 100644 --- a/zrpc/internal/serverinterceptors/breakerinterceptor.go +++ b/zrpc/internal/serverinterceptors/breakerinterceptor.go @@ -9,7 +9,7 @@ import ( ) // StreamBreakerInterceptor is an interceptor that acts as a circuit breaker. -func StreamBreakerInterceptor(svr interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, +func StreamBreakerInterceptor(svr any, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) (err error) { breakerName := info.FullMethod return breaker.DoWithAcceptable(breakerName, func() error { @@ -18,8 +18,8 @@ func StreamBreakerInterceptor(svr interface{}, stream grpc.ServerStream, info *g } // UnaryBreakerInterceptor is an interceptor that acts as a circuit breaker. -func UnaryBreakerInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, - handler grpc.UnaryHandler) (resp interface{}, err error) { +func UnaryBreakerInterceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo, + handler grpc.UnaryHandler) (resp any, err error) { breakerName := info.FullMethod err = breaker.DoWithAcceptable(breakerName, func() error { var err error diff --git a/zrpc/internal/serverinterceptors/breakerinterceptor_test.go b/zrpc/internal/serverinterceptors/breakerinterceptor_test.go index 61f68c71..26538c27 100644 --- a/zrpc/internal/serverinterceptors/breakerinterceptor_test.go +++ b/zrpc/internal/serverinterceptors/breakerinterceptor_test.go @@ -13,7 +13,7 @@ import ( func TestStreamBreakerInterceptor(t *testing.T) { err := StreamBreakerInterceptor(nil, nil, &grpc.StreamServerInfo{ FullMethod: "any", - }, func(_ interface{}, _ grpc.ServerStream) error { + }, func(_ any, _ grpc.ServerStream) error { return status.New(codes.DeadlineExceeded, "any").Err() }) assert.NotNil(t, err) @@ -22,7 +22,7 @@ func TestStreamBreakerInterceptor(t *testing.T) { func TestUnaryBreakerInterceptor(t *testing.T) { _, err := UnaryBreakerInterceptor(context.Background(), nil, &grpc.UnaryServerInfo{ FullMethod: "any", - }, func(_ context.Context, _ interface{}) (interface{}, error) { + }, func(_ context.Context, _ any) (any, error) { return nil, status.New(codes.DeadlineExceeded, "any").Err() }) assert.NotNil(t, err) diff --git a/zrpc/internal/serverinterceptors/prometheusinterceptor.go b/zrpc/internal/serverinterceptors/prometheusinterceptor.go index e6cce1a4..5683dbd2 100644 --- a/zrpc/internal/serverinterceptors/prometheusinterceptor.go +++ b/zrpc/internal/serverinterceptors/prometheusinterceptor.go @@ -33,8 +33,8 @@ var ( ) // UnaryPrometheusInterceptor reports the statistics to the prometheus server. -func UnaryPrometheusInterceptor(ctx context.Context, req interface{}, - info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { +func UnaryPrometheusInterceptor(ctx context.Context, req any, + info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) { startTime := timex.Now() resp, err := handler(ctx, req) metricServerReqDur.Observe(int64(timex.Since(startTime)/time.Millisecond), info.FullMethod) diff --git a/zrpc/internal/serverinterceptors/prometheusinterceptor_test.go b/zrpc/internal/serverinterceptors/prometheusinterceptor_test.go index fe8d5d67..3dbd302a 100644 --- a/zrpc/internal/serverinterceptors/prometheusinterceptor_test.go +++ b/zrpc/internal/serverinterceptors/prometheusinterceptor_test.go @@ -12,7 +12,7 @@ import ( func TestUnaryPromMetricInterceptor_Disabled(t *testing.T) { _, err := UnaryPrometheusInterceptor(context.Background(), nil, &grpc.UnaryServerInfo{ FullMethod: "/", - }, func(ctx context.Context, req interface{}) (interface{}, error) { + }, func(ctx context.Context, req any) (any, error) { return nil, nil }) assert.Nil(t, err) @@ -25,7 +25,7 @@ func TestUnaryPromMetricInterceptor_Enabled(t *testing.T) { }) _, err := UnaryPrometheusInterceptor(context.Background(), nil, &grpc.UnaryServerInfo{ FullMethod: "/", - }, func(ctx context.Context, req interface{}) (interface{}, error) { + }, func(ctx context.Context, req any) (any, error) { return nil, nil }) assert.Nil(t, err) diff --git a/zrpc/internal/serverinterceptors/recoverinterceptor.go b/zrpc/internal/serverinterceptors/recoverinterceptor.go index 01fde7dc..84c4632a 100644 --- a/zrpc/internal/serverinterceptors/recoverinterceptor.go +++ b/zrpc/internal/serverinterceptors/recoverinterceptor.go @@ -11,9 +11,9 @@ import ( ) // StreamRecoverInterceptor catches panics in processing stream requests and recovers. -func StreamRecoverInterceptor(svr interface{}, stream grpc.ServerStream, _ *grpc.StreamServerInfo, +func StreamRecoverInterceptor(svr any, stream grpc.ServerStream, _ *grpc.StreamServerInfo, handler grpc.StreamHandler) (err error) { - defer handleCrash(func(r interface{}) { + defer handleCrash(func(r any) { err = toPanicError(r) }) @@ -21,22 +21,22 @@ func StreamRecoverInterceptor(svr interface{}, stream grpc.ServerStream, _ *grpc } // UnaryRecoverInterceptor catches panics in processing unary requests and recovers. -func UnaryRecoverInterceptor(ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo, - handler grpc.UnaryHandler) (resp interface{}, err error) { - defer handleCrash(func(r interface{}) { +func UnaryRecoverInterceptor(ctx context.Context, req any, _ *grpc.UnaryServerInfo, + handler grpc.UnaryHandler) (resp any, err error) { + defer handleCrash(func(r any) { err = toPanicError(r) }) return handler(ctx, req) } -func handleCrash(handler func(interface{})) { +func handleCrash(handler func(any)) { if r := recover(); r != nil { handler(r) } } -func toPanicError(r interface{}) error { +func toPanicError(r any) error { logx.Errorf("%+v\n\n%s", r, debug.Stack()) return status.Errorf(codes.Internal, "panic: %v", r) } diff --git a/zrpc/internal/serverinterceptors/recoverinterceptor_test.go b/zrpc/internal/serverinterceptors/recoverinterceptor_test.go index 2325bf14..24d39536 100644 --- a/zrpc/internal/serverinterceptors/recoverinterceptor_test.go +++ b/zrpc/internal/serverinterceptors/recoverinterceptor_test.go @@ -15,7 +15,7 @@ func init() { func TestStreamCrashInterceptor(t *testing.T) { err := StreamRecoverInterceptor(nil, nil, nil, func( - svr interface{}, stream grpc.ServerStream) error { + svr any, stream grpc.ServerStream) error { panic("mock panic") }) assert.NotNil(t, err) @@ -23,7 +23,7 @@ func TestStreamCrashInterceptor(t *testing.T) { func TestUnaryCrashInterceptor(t *testing.T) { _, err := UnaryRecoverInterceptor(context.Background(), nil, nil, - func(ctx context.Context, req interface{}) (interface{}, error) { + func(ctx context.Context, req any) (any, error) { panic("mock panic") }) assert.NotNil(t, err) diff --git a/zrpc/internal/serverinterceptors/sheddinginterceptor.go b/zrpc/internal/serverinterceptors/sheddinginterceptor.go index 8f73e222..2b8ac1f1 100644 --- a/zrpc/internal/serverinterceptors/sheddinginterceptor.go +++ b/zrpc/internal/serverinterceptors/sheddinginterceptor.go @@ -20,8 +20,8 @@ var ( func UnarySheddingInterceptor(shedder load.Shedder, metrics *stat.Metrics) grpc.UnaryServerInterceptor { ensureSheddingStat() - return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, - handler grpc.UnaryHandler) (val interface{}, err error) { + return func(ctx context.Context, req any, info *grpc.UnaryServerInfo, + handler grpc.UnaryHandler) (val any, err error) { sheddingStat.IncrementTotal() var promise load.Promise promise, err = shedder.Allow() diff --git a/zrpc/internal/serverinterceptors/sheddinginterceptor_test.go b/zrpc/internal/serverinterceptors/sheddinginterceptor_test.go index 99536166..7b8afde6 100644 --- a/zrpc/internal/serverinterceptors/sheddinginterceptor_test.go +++ b/zrpc/internal/serverinterceptors/sheddinginterceptor_test.go @@ -47,7 +47,7 @@ func TestUnarySheddingInterceptor(t *testing.T) { interceptor := UnarySheddingInterceptor(shedder, metrics) _, err := interceptor(context.Background(), nil, &grpc.UnaryServerInfo{ FullMethod: "/", - }, func(ctx context.Context, req interface{}) (interface{}, error) { + }, func(ctx context.Context, req any) (any, error) { return nil, test.handleErr }) assert.Equal(t, test.expect, err) diff --git a/zrpc/internal/serverinterceptors/statinterceptor.go b/zrpc/internal/serverinterceptors/statinterceptor.go index 492d3d76..7fe957cb 100644 --- a/zrpc/internal/serverinterceptors/statinterceptor.go +++ b/zrpc/internal/serverinterceptors/statinterceptor.go @@ -34,8 +34,8 @@ func SetSlowThreshold(threshold time.Duration) { // UnaryStatInterceptor returns a func that uses given metrics to report stats. func UnaryStatInterceptor(metrics *stat.Metrics) grpc.UnaryServerInterceptor { - return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, - handler grpc.UnaryHandler) (resp interface{}, err error) { + return func(ctx context.Context, req any, info *grpc.UnaryServerInfo, + handler grpc.UnaryHandler) (resp any, err error) { startTime := timex.Now() defer func() { duration := timex.Since(startTime) @@ -49,7 +49,7 @@ func UnaryStatInterceptor(metrics *stat.Metrics) grpc.UnaryServerInterceptor { } } -func logDuration(ctx context.Context, method string, req interface{}, duration time.Duration) { +func logDuration(ctx context.Context, method string, req any, duration time.Duration) { var addr string client, ok := peer.FromContext(ctx) if ok { diff --git a/zrpc/internal/serverinterceptors/statinterceptor_test.go b/zrpc/internal/serverinterceptors/statinterceptor_test.go index c4545851..90223a28 100644 --- a/zrpc/internal/serverinterceptors/statinterceptor_test.go +++ b/zrpc/internal/serverinterceptors/statinterceptor_test.go @@ -24,7 +24,7 @@ func TestUnaryStatInterceptor(t *testing.T) { interceptor := UnaryStatInterceptor(metrics) _, err := interceptor(context.Background(), nil, &grpc.UnaryServerInfo{ FullMethod: "/", - }, func(ctx context.Context, req interface{}) (interface{}, error) { + }, func(ctx context.Context, req any) (any, error) { return nil, nil }) assert.Nil(t, err) @@ -38,7 +38,7 @@ func TestLogDuration(t *testing.T) { tests := []struct { name string ctx context.Context - req interface{} + req any duration time.Duration }{ { @@ -92,7 +92,7 @@ func TestLogDurationWithoutContent(t *testing.T) { tests := []struct { name string ctx context.Context - req interface{} + req any duration time.Duration }{ { diff --git a/zrpc/internal/serverinterceptors/timeoutinterceptor.go b/zrpc/internal/serverinterceptors/timeoutinterceptor.go index 68937201..27cded03 100644 --- a/zrpc/internal/serverinterceptors/timeoutinterceptor.go +++ b/zrpc/internal/serverinterceptors/timeoutinterceptor.go @@ -15,17 +15,17 @@ import ( // UnaryTimeoutInterceptor returns a func that sets timeout to incoming unary requests. func UnaryTimeoutInterceptor(timeout time.Duration) grpc.UnaryServerInterceptor { - return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, - handler grpc.UnaryHandler) (interface{}, error) { + return func(ctx context.Context, req any, info *grpc.UnaryServerInfo, + handler grpc.UnaryHandler) (any, error) { ctx, cancel := context.WithTimeout(ctx, timeout) defer cancel() - var resp interface{} + var resp any var err error var lock sync.Mutex done := make(chan struct{}) // create channel with buffer size 1 to avoid goroutine leak - panicChan := make(chan interface{}, 1) + panicChan := make(chan any, 1) go func() { defer func() { if p := recover(); p != nil { diff --git a/zrpc/internal/serverinterceptors/timeoutinterceptor_test.go b/zrpc/internal/serverinterceptors/timeoutinterceptor_test.go index 2c18411b..0e89eac6 100644 --- a/zrpc/internal/serverinterceptors/timeoutinterceptor_test.go +++ b/zrpc/internal/serverinterceptors/timeoutinterceptor_test.go @@ -16,7 +16,7 @@ func TestUnaryTimeoutInterceptor(t *testing.T) { interceptor := UnaryTimeoutInterceptor(time.Millisecond * 10) _, err := interceptor(context.Background(), nil, &grpc.UnaryServerInfo{ FullMethod: "/", - }, func(ctx context.Context, req interface{}) (interface{}, error) { + }, func(ctx context.Context, req any) (any, error) { return nil, nil }) assert.Nil(t, err) @@ -27,7 +27,7 @@ func TestUnaryTimeoutInterceptor_panic(t *testing.T) { assert.Panics(t, func() { _, _ = interceptor(context.Background(), nil, &grpc.UnaryServerInfo{ FullMethod: "/", - }, func(ctx context.Context, req interface{}) (interface{}, error) { + }, func(ctx context.Context, req any) (any, error) { panic("any") }) }) @@ -42,7 +42,7 @@ func TestUnaryTimeoutInterceptor_timeout(t *testing.T) { wg.Add(1) _, err := interceptor(ctx, nil, &grpc.UnaryServerInfo{ FullMethod: "/", - }, func(ctx context.Context, req interface{}) (interface{}, error) { + }, func(ctx context.Context, req any) (any, error) { defer wg.Done() tm, ok := ctx.Deadline() assert.True(t, ok) @@ -62,7 +62,7 @@ func TestUnaryTimeoutInterceptor_timeoutExpire(t *testing.T) { wg.Add(1) _, err := interceptor(ctx, nil, &grpc.UnaryServerInfo{ FullMethod: "/", - }, func(ctx context.Context, req interface{}) (interface{}, error) { + }, func(ctx context.Context, req any) (any, error) { defer wg.Done() time.Sleep(time.Millisecond * 50) return nil, nil @@ -81,7 +81,7 @@ func TestUnaryTimeoutInterceptor_cancel(t *testing.T) { wg.Add(1) _, err := interceptor(ctx, nil, &grpc.UnaryServerInfo{ FullMethod: "/", - }, func(ctx context.Context, req interface{}) (interface{}, error) { + }, func(ctx context.Context, req any) (any, error) { defer wg.Done() time.Sleep(time.Millisecond * 50) return nil, nil diff --git a/zrpc/internal/serverinterceptors/tracinginterceptor.go b/zrpc/internal/serverinterceptors/tracinginterceptor.go index 788ca4cb..b64a0c17 100644 --- a/zrpc/internal/serverinterceptors/tracinginterceptor.go +++ b/zrpc/internal/serverinterceptors/tracinginterceptor.go @@ -15,8 +15,8 @@ import ( ) // UnaryTracingInterceptor is a grpc.UnaryServerInterceptor for opentelemetry. -func UnaryTracingInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, - handler grpc.UnaryHandler) (interface{}, error) { +func UnaryTracingInterceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo, + handler grpc.UnaryHandler) (any, error) { ctx, span := startSpan(ctx, info.FullMethod) defer span.End() @@ -41,7 +41,7 @@ func UnaryTracingInterceptor(ctx context.Context, req interface{}, info *grpc.Un } // StreamTracingInterceptor returns a grpc.StreamServerInterceptor for opentelemetry. -func StreamTracingInterceptor(svr interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, +func StreamTracingInterceptor(svr any, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { ctx, span := startSpan(ss.Context(), info.FullMethod) defer span.End() @@ -74,7 +74,7 @@ func (w *serverStream) Context() context.Context { return w.ctx } -func (w *serverStream) RecvMsg(m interface{}) error { +func (w *serverStream) RecvMsg(m any) error { err := w.ServerStream.RecvMsg(m) if err == nil { w.receivedMessageID++ @@ -84,7 +84,7 @@ func (w *serverStream) RecvMsg(m interface{}) error { return err } -func (w *serverStream) SendMsg(m interface{}) error { +func (w *serverStream) SendMsg(m any) error { err := w.ServerStream.SendMsg(m) w.sentMessageID++ ztrace.MessageSent.Event(w.Context(), w.sentMessageID, m) diff --git a/zrpc/internal/serverinterceptors/tracinginterceptor_test.go b/zrpc/internal/serverinterceptors/tracinginterceptor_test.go index 81c53ce5..d6afb5ab 100644 --- a/zrpc/internal/serverinterceptors/tracinginterceptor_test.go +++ b/zrpc/internal/serverinterceptors/tracinginterceptor_test.go @@ -19,7 +19,7 @@ import ( func TestUnaryOpenTracingInterceptor_Disable(t *testing.T) { _, err := UnaryTracingInterceptor(context.Background(), nil, &grpc.UnaryServerInfo{ FullMethod: "/", - }, func(ctx context.Context, req interface{}) (interface{}, error) { + }, func(ctx context.Context, req any) (any, error) { return nil, nil }) assert.Nil(t, err) @@ -36,7 +36,7 @@ func TestUnaryOpenTracingInterceptor_Enabled(t *testing.T) { _, err := UnaryTracingInterceptor(context.Background(), nil, &grpc.UnaryServerInfo{ FullMethod: "/package.TestService.GetUser", - }, func(ctx context.Context, req interface{}) (interface{}, error) { + }, func(ctx context.Context, req any) (any, error) { return nil, nil }) assert.Nil(t, err) @@ -48,7 +48,7 @@ func TestUnaryTracingInterceptor(t *testing.T) { wg.Add(1) _, err := UnaryTracingInterceptor(context.Background(), nil, &grpc.UnaryServerInfo{ FullMethod: "/", - }, func(ctx context.Context, req interface{}) (interface{}, error) { + }, func(ctx context.Context, req any) (any, error) { defer wg.Done() atomic.AddInt32(&run, 1) return nil, nil @@ -84,7 +84,7 @@ func TestUnaryTracingInterceptor_WithError(t *testing.T) { ctx := metadata.NewIncomingContext(context.Background(), md) _, err := UnaryTracingInterceptor(ctx, nil, &grpc.UnaryServerInfo{ FullMethod: "/", - }, func(ctx context.Context, req interface{}) (interface{}, error) { + }, func(ctx context.Context, req any) (any, error) { defer wg.Done() return nil, test.err }) @@ -103,7 +103,7 @@ func TestStreamTracingInterceptor_GrpcFormat(t *testing.T) { stream := mockedServerStream{ctx: ctx} err := StreamTracingInterceptor(nil, &stream, &grpc.StreamServerInfo{ FullMethod: "/foo", - }, func(svr interface{}, stream grpc.ServerStream) error { + }, func(svr any, stream grpc.ServerStream) error { defer wg.Done() atomic.AddInt32(&run, 1) return nil @@ -140,7 +140,7 @@ func TestStreamTracingInterceptor_FinishWithGrpcError(t *testing.T) { stream := mockedServerStream{ctx: ctx} err := StreamTracingInterceptor(nil, &stream, &grpc.StreamServerInfo{ FullMethod: "/foo", - }, func(svr interface{}, stream grpc.ServerStream) error { + }, func(svr any, stream grpc.ServerStream) error { defer wg.Done() return test.err }) @@ -177,7 +177,7 @@ func TestStreamTracingInterceptor_WithError(t *testing.T) { stream := mockedServerStream{ctx: ctx} err := StreamTracingInterceptor(nil, &stream, &grpc.StreamServerInfo{ FullMethod: "/foo", - }, func(svr interface{}, stream grpc.ServerStream) error { + }, func(svr any, stream grpc.ServerStream) error { defer wg.Done() return test.err }) @@ -270,10 +270,10 @@ func (m *mockedServerStream) Context() context.Context { return m.ctx } -func (m *mockedServerStream) SendMsg(v interface{}) error { +func (m *mockedServerStream) SendMsg(v any) error { return m.err } -func (m *mockedServerStream) RecvMsg(v interface{}) error { +func (m *mockedServerStream) RecvMsg(v any) error { return m.err } diff --git a/zrpc/proxy.go b/zrpc/proxy.go index 7bb997f8..c9fb37e5 100644 --- a/zrpc/proxy.go +++ b/zrpc/proxy.go @@ -33,7 +33,7 @@ func NewProxy(backend string, opts ...internal.ClientOption) *RpcProxy { func (p *RpcProxy) TakeConn(ctx context.Context) (*grpc.ClientConn, error) { cred := auth.ParseCredential(ctx) key := cred.App + "/" + cred.Token - val, err := p.singleFlight.Do(key, func() (interface{}, error) { + val, err := p.singleFlight.Do(key, func() (any, error) { p.lock.Lock() client, ok := p.clients[key] p.lock.Unlock() diff --git a/zrpc/resolver/internal/kube/eventhandler.go b/zrpc/resolver/internal/kube/eventhandler.go index e247ce0b..44a8ff7a 100644 --- a/zrpc/resolver/internal/kube/eventhandler.go +++ b/zrpc/resolver/internal/kube/eventhandler.go @@ -24,7 +24,7 @@ func NewEventHandler(update func([]string)) *EventHandler { } // OnAdd handles the endpoints add events. -func (h *EventHandler) OnAdd(obj interface{}) { +func (h *EventHandler) OnAdd(obj any) { endpoints, ok := obj.(*v1.Endpoints) if !ok { logx.Errorf("%v is not an object with type *v1.Endpoints", obj) @@ -50,7 +50,7 @@ func (h *EventHandler) OnAdd(obj interface{}) { } // OnDelete handles the endpoints delete events. -func (h *EventHandler) OnDelete(obj interface{}) { +func (h *EventHandler) OnDelete(obj any) { endpoints, ok := obj.(*v1.Endpoints) if !ok { logx.Errorf("%v is not an object with type *v1.Endpoints", obj) @@ -76,7 +76,7 @@ func (h *EventHandler) OnDelete(obj interface{}) { } // OnUpdate handles the endpoints update events. -func (h *EventHandler) OnUpdate(oldObj, newObj interface{}) { +func (h *EventHandler) OnUpdate(oldObj, newObj any) { oldEndpoints, ok := oldObj.(*v1.Endpoints) if !ok { logx.Errorf("%v is not an object with type *v1.Endpoints", oldObj) diff --git a/zrpc/resolver/internal/subset_test.go b/zrpc/resolver/internal/subset_test.go index 06a6ddf2..129286a4 100644 --- a/zrpc/resolver/internal/subset_test.go +++ b/zrpc/resolver/internal/subset_test.go @@ -34,7 +34,7 @@ func TestSubset(t *testing.T) { vals = append(vals, strconv.Itoa(i)) } - m := make(map[interface{}]int) + m := make(map[any]int) for i := 0; i < 1000; i++ { set := subset(append([]string(nil), vals...), test.sub) if test.sub < test.set {