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:
@@ -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)]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user