summaryrefslogtreecommitdiff
path: root/lib/containers
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2023-01-01 19:33:03 -0700
committerLuke Shumaker <lukeshu@lukeshu.com>2023-01-01 22:42:08 -0700
commita06a7fb2d5bbf1ca5659de06fc9e975666bdcf9f (patch)
tree268aaa2725e4ad336412118779377177601c662b /lib/containers
parentc307e7048da3c02e1e540eab227def7fec7340cc (diff)
lint: Turn on gofumpt
All edits to .go files are made by `tools/bin/golangci-lint run --fix ./...`, not by me as a human.
Diffstat (limited to 'lib/containers')
-rw-r--r--lib/containers/lru.go7
-rw-r--r--lib/containers/syncmap.go5
2 files changed, 12 insertions, 0 deletions
diff --git a/lib/containers/lru.go b/lib/containers/lru.go
index 12446b0..bfda361 100644
--- a/lib/containers/lru.go
+++ b/lib/containers/lru.go
@@ -36,10 +36,12 @@ func (c *LRUCache[K, V]) Add(key K, value V) {
c.init()
c.inner.Add(key, value)
}
+
func (c *LRUCache[K, V]) Contains(key K) bool {
c.init()
return c.inner.Contains(key)
}
+
func (c *LRUCache[K, V]) Get(key K) (value V, ok bool) {
c.init()
_value, ok := c.inner.Get(key)
@@ -49,6 +51,7 @@ func (c *LRUCache[K, V]) Get(key K) (value V, ok bool) {
}
return value, ok
}
+
func (c *LRUCache[K, V]) Keys() []K {
c.init()
untyped := c.inner.Keys()
@@ -59,10 +62,12 @@ func (c *LRUCache[K, V]) Keys() []K {
}
return typed
}
+
func (c *LRUCache[K, V]) Len() int {
c.init()
return c.inner.Len()
}
+
func (c *LRUCache[K, V]) Peek(key K) (value V, ok bool) {
c.init()
_value, ok := c.inner.Peek(key)
@@ -72,10 +77,12 @@ func (c *LRUCache[K, V]) Peek(key K) (value V, ok bool) {
}
return value, ok
}
+
func (c *LRUCache[K, V]) Purge() {
c.init()
c.inner.Purge()
}
+
func (c *LRUCache[K, V]) Remove(key K) {
c.init()
c.inner.Remove(key)
diff --git a/lib/containers/syncmap.go b/lib/containers/syncmap.go
index 4af678f..74da4b3 100644
--- a/lib/containers/syncmap.go
+++ b/lib/containers/syncmap.go
@@ -15,6 +15,7 @@ type SyncMap[K comparable, V any] struct {
func (m *SyncMap[K, V]) Delete(key K) {
m.inner.Delete(key)
}
+
func (m *SyncMap[K, V]) Load(key K) (value V, ok bool) {
_value, ok := m.inner.Load(key)
if ok {
@@ -23,6 +24,7 @@ func (m *SyncMap[K, V]) Load(key K) (value V, ok bool) {
}
return value, ok
}
+
func (m *SyncMap[K, V]) LoadAndDelete(key K) (value V, loaded bool) {
_value, ok := m.inner.LoadAndDelete(key)
if ok {
@@ -31,18 +33,21 @@ func (m *SyncMap[K, V]) LoadAndDelete(key K) (value V, loaded bool) {
}
return value, ok
}
+
func (m *SyncMap[K, V]) LoadOrStore(key K, value V) (actual V, loaded bool) {
_actual, loaded := m.inner.LoadOrStore(key, value)
//nolint:forcetypeassert // Typed wrapper around untyped lib.
actual = _actual.(V)
return actual, loaded
}
+
func (m *SyncMap[K, V]) Range(f func(key K, value V) bool) {
m.inner.Range(func(key, value any) bool {
//nolint:forcetypeassert // Typed wrapper around untyped lib.
return f(key.(K), value.(V))
})
}
+
func (m *SyncMap[K, V]) Store(key K, value V) {
m.inner.Store(key, value)
}