diff --git a/internal/lib/collection.go b/internal/lib/collection.go index 613d8da..6a9cba3 100644 --- a/internal/lib/collection.go +++ b/internal/lib/collection.go @@ -12,7 +12,7 @@ type Collection struct { // Item just interface for stoing any data. type item struct { - data interface{} + data any } // NewCollection creates new instance of "collection". @@ -25,7 +25,7 @@ func NewCollection() *Collection { } // Get returns value by given key. Or empty value. -func (collection *Collection) Get(key interface{}) (interface{}, bool) { +func (collection *Collection) Get(key any) (any, bool) { obj, exists := collection.items.Load(key) if !exists { @@ -38,15 +38,15 @@ func (collection *Collection) Get(key interface{}) (interface{}, bool) { } // Set saves value to given "collection". -func (collection *Collection) Set(key interface{}, value interface{}) { +func (collection *Collection) Set(key any, value any) { collection.items.Store(key, item{ data: value, }) } // Range apply function f to all keys/values in collection. Retuns immediatly on first error. -func (collection *Collection) Range(f func(key, value interface{}) bool) { - fn := func(key, value interface{}) bool { +func (collection *Collection) Range(f func(key, value any) bool) { + fn := func(key, value any) bool { item := value.(item) return f(key, item.data) @@ -56,7 +56,7 @@ func (collection *Collection) Range(f func(key, value interface{}) bool) { } // Delete deletes key and corresponding value from collection. -func (collection *Collection) Delete(key interface{}) { +func (collection *Collection) Delete(key any) { collection.items.Delete(key) } diff --git a/internal/lib/config.go b/internal/lib/config.go index c63726c..309c97f 100644 --- a/internal/lib/config.go +++ b/internal/lib/config.go @@ -302,7 +302,7 @@ func ReadConf(defaultConfig []byte) (*MyConfig, error) { // then produced json unmarshal to struct. Not very effective way, but in app lifetime it happens only once. var ( sampleConfig *MyConfig - tmp map[string]interface{} + tmp map[string]any ) err = hjson.Unmarshal(buf, &tmp)