Replace interface{} with any (#25686)

Result of running `perl -p -i -e 's#interface\{\}#any#g' **/*` and `make fmt`.

Basically the same [as golang did](2580d0e08d).
This commit is contained in:
silverwind 2023-07-04 20:36:08 +02:00 committed by GitHub
parent 00dbba7f42
commit 88f835192d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
233 changed files with 727 additions and 727 deletions

View file

@ -17,11 +17,11 @@ import (
type DBStore struct {
sid string
lock sync.RWMutex
data map[interface{}]interface{}
data map[any]any
}
// NewDBStore creates and returns a DB session store.
func NewDBStore(sid string, kv map[interface{}]interface{}) *DBStore {
func NewDBStore(sid string, kv map[any]any) *DBStore {
return &DBStore{
sid: sid,
data: kv,
@ -29,7 +29,7 @@ func NewDBStore(sid string, kv map[interface{}]interface{}) *DBStore {
}
// Set sets value to given key in session.
func (s *DBStore) Set(key, val interface{}) error {
func (s *DBStore) Set(key, val any) error {
s.lock.Lock()
defer s.lock.Unlock()
@ -38,7 +38,7 @@ func (s *DBStore) Set(key, val interface{}) error {
}
// Get gets value by given key in session.
func (s *DBStore) Get(key interface{}) interface{} {
func (s *DBStore) Get(key any) any {
s.lock.RLock()
defer s.lock.RUnlock()
@ -46,7 +46,7 @@ func (s *DBStore) Get(key interface{}) interface{} {
}
// Delete delete a key from session.
func (s *DBStore) Delete(key interface{}) error {
func (s *DBStore) Delete(key any) error {
s.lock.Lock()
defer s.lock.Unlock()
@ -79,7 +79,7 @@ func (s *DBStore) Flush() error {
s.lock.Lock()
defer s.lock.Unlock()
s.data = make(map[interface{}]interface{})
s.data = make(map[any]any)
return nil
}
@ -102,9 +102,9 @@ func (p *DBProvider) Read(sid string) (session.RawStore, error) {
return nil, err
}
var kv map[interface{}]interface{}
var kv map[any]any
if len(s.Data) == 0 || s.Expiry.Add(p.maxLifetime) <= timeutil.TimeStampNow() {
kv = make(map[interface{}]interface{})
kv = make(map[any]any)
} else {
kv, err = session.DecodeGob(s.Data)
if err != nil {
@ -136,9 +136,9 @@ func (p *DBProvider) Regenerate(oldsid, sid string) (_ session.RawStore, err err
return nil, err
}
var kv map[interface{}]interface{}
var kv map[any]any
if len(s.Data) == 0 || s.Expiry.Add(p.maxLifetime) <= timeutil.TimeStampNow() {
kv = make(map[interface{}]interface{})
kv = make(map[any]any)
} else {
kv, err = session.DecodeGob(s.Data)
if err != nil {

View file

@ -35,11 +35,11 @@ type RedisStore struct {
prefix, sid string
duration time.Duration
lock sync.RWMutex
data map[interface{}]interface{}
data map[any]any
}
// NewRedisStore creates and returns a redis session store.
func NewRedisStore(c redis.UniversalClient, prefix, sid string, dur time.Duration, kv map[interface{}]interface{}) *RedisStore {
func NewRedisStore(c redis.UniversalClient, prefix, sid string, dur time.Duration, kv map[any]any) *RedisStore {
return &RedisStore{
c: c,
prefix: prefix,
@ -50,7 +50,7 @@ func NewRedisStore(c redis.UniversalClient, prefix, sid string, dur time.Duratio
}
// Set sets value to given key in session.
func (s *RedisStore) Set(key, val interface{}) error {
func (s *RedisStore) Set(key, val any) error {
s.lock.Lock()
defer s.lock.Unlock()
@ -59,7 +59,7 @@ func (s *RedisStore) Set(key, val interface{}) error {
}
// Get gets value by given key in session.
func (s *RedisStore) Get(key interface{}) interface{} {
func (s *RedisStore) Get(key any) any {
s.lock.RLock()
defer s.lock.RUnlock()
@ -67,7 +67,7 @@ func (s *RedisStore) Get(key interface{}) interface{} {
}
// Delete delete a key from session.
func (s *RedisStore) Delete(key interface{}) error {
func (s *RedisStore) Delete(key any) error {
s.lock.Lock()
defer s.lock.Unlock()
@ -100,7 +100,7 @@ func (s *RedisStore) Flush() error {
s.lock.Lock()
defer s.lock.Unlock()
s.data = make(map[interface{}]interface{})
s.data = make(map[any]any)
return nil
}
@ -141,13 +141,13 @@ func (p *RedisProvider) Read(sid string) (session.RawStore, error) {
}
}
var kv map[interface{}]interface{}
var kv map[any]any
kvs, err := p.c.Get(graceful.GetManager().HammerContext(), psid).Result()
if err != nil {
return nil, err
}
if len(kvs) == 0 {
kv = make(map[interface{}]interface{})
kv = make(map[any]any)
} else {
kv, err = session.DecodeGob([]byte(kvs))
if err != nil {
@ -197,9 +197,9 @@ func (p *RedisProvider) Regenerate(oldsid, sid string) (_ session.RawStore, err
return nil, err
}
var kv map[interface{}]interface{}
var kv map[any]any
if len(kvs) == 0 {
kv = make(map[interface{}]interface{})
kv = make(map[any]any)
} else {
kv, err = session.DecodeGob([]byte(kvs))
if err != nil {

View file

@ -11,9 +11,9 @@ import (
// Store represents a session store
type Store interface {
Get(interface{}) interface{}
Set(interface{}, interface{}) error
Delete(interface{}) error
Get(any) any
Set(any, any) error
Delete(any) error
}
// RegenerateSession regenerates the underlying session and returns the new store

View file

@ -62,7 +62,7 @@ func (o *VirtualSessionProvider) Read(sid string) (session.RawStore, error) {
if o.provider.Exist(sid) {
return o.provider.Read(sid)
}
kv := make(map[interface{}]interface{})
kv := make(map[any]any)
kv["_old_uid"] = "0"
return NewVirtualStore(o, sid, kv), nil
}
@ -107,12 +107,12 @@ type VirtualStore struct {
p *VirtualSessionProvider
sid string
lock sync.RWMutex
data map[interface{}]interface{}
data map[any]any
released bool
}
// NewVirtualStore creates and returns a virtual session store.
func NewVirtualStore(p *VirtualSessionProvider, sid string, kv map[interface{}]interface{}) *VirtualStore {
func NewVirtualStore(p *VirtualSessionProvider, sid string, kv map[any]any) *VirtualStore {
return &VirtualStore{
p: p,
sid: sid,
@ -121,7 +121,7 @@ func NewVirtualStore(p *VirtualSessionProvider, sid string, kv map[interface{}]i
}
// Set sets value to given key in session.
func (s *VirtualStore) Set(key, val interface{}) error {
func (s *VirtualStore) Set(key, val any) error {
s.lock.Lock()
defer s.lock.Unlock()
@ -130,7 +130,7 @@ func (s *VirtualStore) Set(key, val interface{}) error {
}
// Get gets value by given key in session.
func (s *VirtualStore) Get(key interface{}) interface{} {
func (s *VirtualStore) Get(key any) any {
s.lock.RLock()
defer s.lock.RUnlock()
@ -138,7 +138,7 @@ func (s *VirtualStore) Get(key interface{}) interface{} {
}
// Delete delete a key from session.
func (s *VirtualStore) Delete(key interface{}) error {
func (s *VirtualStore) Delete(key any) error {
s.lock.Lock()
defer s.lock.Unlock()
@ -192,6 +192,6 @@ func (s *VirtualStore) Flush() error {
s.lock.Lock()
defer s.lock.Unlock()
s.data = make(map[interface{}]interface{})
s.data = make(map[any]any)
return nil
}