fix: 优化 go1.21 以下项目的兼容性
This commit is contained in:
parent
a1c15a2c26
commit
ab90fa8928
|
@ -3,6 +3,7 @@ package counter
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/kercylan98/minotaur/utils/generic"
|
"github.com/kercylan98/minotaur/utils/generic"
|
||||||
|
"github.com/kercylan98/minotaur/utils/hash"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
@ -151,9 +152,9 @@ func (slf *Counter[K, V]) ResetExpiredMark(mark, key K) {
|
||||||
// ResetAll 重置所有计数
|
// ResetAll 重置所有计数
|
||||||
func (slf *Counter[K, V]) ResetAll() {
|
func (slf *Counter[K, V]) ResetAll() {
|
||||||
slf.lock.Lock()
|
slf.lock.Lock()
|
||||||
clear(slf.c)
|
hash.Clear(slf.c)
|
||||||
clear(slf.dr)
|
hash.Clear(slf.dr)
|
||||||
clear(slf.drm)
|
hash.Clear(slf.drm)
|
||||||
slf.lock.Unlock()
|
slf.lock.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ func (slf *Priority[V]) Cap() int {
|
||||||
|
|
||||||
// Clear 清空切片
|
// Clear 清空切片
|
||||||
func (slf *Priority[V]) Clear() {
|
func (slf *Priority[V]) Clear() {
|
||||||
clear(slf.items)
|
slf.items = slf.items[:0]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Append 添加元素
|
// Append 添加元素
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package sole
|
package sole
|
||||||
|
|
||||||
|
import "github.com/kercylan98/minotaur/utils/hash"
|
||||||
|
|
||||||
// NewOnce 创建一个用于数据取值去重的结构实例
|
// NewOnce 创建一个用于数据取值去重的结构实例
|
||||||
func NewOnce[V any]() *Once[V] {
|
func NewOnce[V any]() *Once[V] {
|
||||||
once := &Once[V]{
|
once := &Once[V]{
|
||||||
|
@ -31,5 +33,5 @@ func (slf *Once[V]) Reset(key ...any) {
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
clear(slf.r)
|
hash.Clear(slf.r)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue