diff --git a/cache/cache.go b/cache/cache.go index 52be7b6..5d8b1a5 100644 --- a/cache/cache.go +++ b/cache/cache.go @@ -7,7 +7,7 @@ import ( ) type Item struct { - value interface{} + value any expiration int64 } @@ -22,7 +22,7 @@ type Cache struct { func (c *Cache) DeleteExpired() { now := time.Now().UnixNano() - c.items.Range(func(key, value interface{}) bool { + c.items.Range(func(key, value any) bool { if value := value.(*Item); value.expiration > 0 && now > value.expiration { c.items.Delete(key) } @@ -58,7 +58,7 @@ func New(defaultExpiration, gcInterval time.Duration) *Cache { return c } -func (c *Cache) Active(key interface{}, d time.Duration) { +func (c *Cache) Active(key any, d time.Duration) { v, ok := c.items.Load(key) if ok { v := v.(*Item) @@ -77,7 +77,7 @@ func (c *Cache) Active(key interface{}, d time.Duration) { } } -func (c *Cache) Set(key, value interface{}, d time.Duration) { +func (c *Cache) Set(key, value any, d time.Duration) { var e int64 if d == 0 { @@ -91,7 +91,7 @@ func (c *Cache) Set(key, value interface{}, d time.Duration) { c.items.Store(key, &Item{value, e}) } -func (c *Cache) Get(key interface{}) (interface{}, bool) { +func (c *Cache) Get(key any) (any, bool) { v, ok := c.items.Load(key) if ok { v := v.(*Item) @@ -101,7 +101,7 @@ func (c *Cache) Get(key interface{}) (interface{}, bool) { return nil, false } -func (c *Cache) Del(key interface{}) { +func (c *Cache) Del(key any) { c.items.Delete(key) } diff --git a/config/config.go b/config/config.go index 4dd411b..85a4065 100644 --- a/config/config.go +++ b/config/config.go @@ -32,7 +32,7 @@ type Config struct { SeparateSslConfig bool } -func getConfigOpt(yamlCfg *yaml.File, name string, opt interface{}) { +func getConfigOpt(yamlCfg *yaml.File, name string, opt any) { val, err := yamlCfg.Get(name) if err != nil { return @@ -89,7 +89,7 @@ func parseYamlCfg(cfg *Config, conf string) error { return nil } -func getFlagOpt(c *cli.Context, name string, opt interface{}) { +func getFlagOpt(c *cli.Context, name string, opt any) { if !c.IsSet(name) { return }