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

* chore: change interface{} to any

* chore: update goctl version to 1.5.0

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

View File

@@ -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)]
}