diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2023-01-01 19:33:03 -0700 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2023-01-01 22:42:08 -0700 |
commit | 2ca0e039e740a1a3b0c8bce7ca6dd6647f0a5319 (patch) | |
tree | ad9a959c3b46a4e1939d5f7a90bb10f7dad7201e | |
parent | 5e2e69cdd2bd66544191e459b77e0b3e15254196 (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.
-rw-r--r-- | .golangci.yml | 1 | ||||
-rw-r--r-- | lib/containers/syncmap.go | 5 |
2 files changed, 5 insertions, 1 deletions
diff --git a/.golangci.yml b/.golangci.yml index 953b512..edb8499 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -35,7 +35,6 @@ linters: - godot - godox - goerr113 - - gofumpt - gomnd - gomoddirectives - ireturn 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) } |