diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index bab5654..23a01ed 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -12,7 +12,7 @@ jobs: name: check (${{ matrix.go}}) strategy: matrix: - go: [1.23, 1.24, 1.25] + go: [1.24, 1.25, 1.26] continue-on-error: true steps: - uses: EarthBuild/actions-setup@main diff --git a/.golangci.yml b/.golangci.yml index 585679d..ebab13e 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -10,6 +10,7 @@ linters: - nonamedreturns - testpackage - varnamelen + - wsl # deprecated exclusions: generated: lax presets: diff --git a/Earthfile b/Earthfile index 3426f9f..cb96497 100644 --- a/Earthfile +++ b/Earthfile @@ -1,5 +1,6 @@ VERSION 0.8 -ARG go_version=1.25.1 +# renovate: datasource=docker depName=golang +ARG go_version=1.26.0 FROM golang:$go_version-alpine WORKDIR /src @@ -15,7 +16,8 @@ src: # lint runs all linters for golang lint: - ARG golangci_lint_version=2.4.0 + # renovate: datasource=docker depName=golangci/golangci-lint + ARG golangci_lint_version=2.9.0 FROM golangci/golangci-lint:v$golangci_lint_version-alpine WORKDIR /src COPY .golangci.yml . diff --git a/go.mod b/go.mod index 9d1060b..59005a1 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,6 @@ module go.expect.digital/cache go 1.24.0 -toolchain go1.25.7 +toolchain go1.26.0 require golang.org/x/sync v0.19.0 diff --git a/internal/list/list.go b/internal/linked/list.go similarity index 99% rename from internal/list/list.go rename to internal/linked/list.go index 7dc6811..713c9a1 100644 --- a/internal/list/list.go +++ b/internal/linked/list.go @@ -1,4 +1,4 @@ -package list +package linked // Element represents a list element. type Element[V any] struct { diff --git a/internal/list/list_test.go b/internal/linked/list_test.go similarity index 99% rename from internal/list/list_test.go rename to internal/linked/list_test.go index 7392b4e..9bd8af2 100644 --- a/internal/list/list_test.go +++ b/internal/linked/list_test.go @@ -1,4 +1,4 @@ -package list +package linked import ( "testing" diff --git a/lru/lru.go b/lru/lru.go index ae2d6f1..793e122 100644 --- a/lru/lru.go +++ b/lru/lru.go @@ -7,7 +7,7 @@ import ( "sync" "time" - "go.expect.digital/cache/internal/list" + "go.expect.digital/cache/internal/linked" ) const defaultSize = 1024 @@ -32,8 +32,8 @@ type Cache[K comparable, V any] struct { ttl time.Duration getter Getter[K, V] onEvict OnEvict[V] - cache *list.List[listValue[K, V]] - lookup map[K]*list.Element[listValue[K, V]] + cache *linked.List[listValue[K, V]] + lookup map[K]*linked.Element[listValue[K, V]] pending map[K][]chan getterResult[V] mu sync.RWMutex } @@ -228,7 +228,7 @@ func (c *Cache[K, V]) Set(ctx context.Context, key K, value V) error { } // evict removes the element from the cache. -func (c *Cache[K, V]) evict(ctx context.Context, el *list.Element[listValue[K, V]]) (err error) { +func (c *Cache[K, V]) evict(ctx context.Context, el *linked.Element[listValue[K, V]]) (err error) { c.cache.Remove(el) delete(c.lookup, el.Value.key) @@ -346,8 +346,8 @@ func New[K comparable, V any](options ...Option[K, V]) *Cache[K, V] { c.n = defaultSize } - c.cache = list.New[listValue[K, V]]() - c.lookup = make(map[K]*list.Element[listValue[K, V]]) + c.cache = linked.New[listValue[K, V]]() + c.lookup = make(map[K]*linked.Element[listValue[K, V]]) c.pending = make(map[K][]chan getterResult[V]) return c