Skip to content

Commit f9f5805

Browse files
committed
chore: bump rekres and add functions from exp
Add some relevant functions from exp/slices and exp/maps Signed-off-by: Dmitriy Matrenichev <[email protected]>
1 parent b968d21 commit f9f5805

File tree

9 files changed

+98
-24
lines changed

9 files changed

+98
-24
lines changed

.drone.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
33
#
4-
# Generated on 2022-09-21T14:24:31Z by kres 943ad34.
4+
# Generated on 2023-05-11T13:47:02Z by kres latest.
55

66
kind: pipeline
77
type: kubernetes
@@ -174,7 +174,7 @@ steps:
174174

175175
services:
176176
- name: docker
177-
image: docker:20.10-dind
177+
image: docker:23.0-dind
178178
entrypoint:
179179
- dockerd
180180
commands:
@@ -212,6 +212,10 @@ trigger:
212212
exclude:
213213
- renovate/*
214214
- dependabot/*
215+
event:
216+
exclude:
217+
- promote
218+
- cron
215219

216220
---
217221
kind: pipeline

.golangci.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
22
#
3-
# Generated on 2022-09-21T14:24:31Z by kres 943ad34.
3+
# Generated on 2023-05-11T13:47:02Z by kres latest.
44

55
# options for analysis running
66
run:
@@ -150,6 +150,12 @@ linters:
150150
- maligned
151151
- golint
152152
- scopelint
153+
- varcheck
154+
- deadcode
155+
- structcheck
156+
- ifshort
157+
# disabled as it seems to be broken - goes into imported libraries and reports issues there
158+
- musttag
153159

154160
issues:
155161
exclude: []

Dockerfile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
# syntax = docker/dockerfile-upstream:1.2.0-labs
1+
# syntax = docker/dockerfile-upstream:1.5.2-labs
22

33
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
44
#
5-
# Generated on 2022-11-28T15:27:14Z by kres 3ac53a8.
5+
# Generated on 2023-05-11T13:47:02Z by kres latest.
66

77
ARG TOOLCHAIN
88

99
# cleaned up specs and compiled versions
1010
FROM scratch AS generate
1111

1212
# runs markdownlint
13-
FROM docker.io/node:19.0.1-alpine3.16 AS lint-markdown
13+
FROM docker.io/node:20.1.0-alpine3.17 AS lint-markdown
1414
WORKDIR /src
15-
RUN npm i -g markdownlint-cli@0.32.2
15+
RUN npm i -g markdownlint-cli@0.34.0
1616
1717
COPY .markdownlint.json .
1818
COPY ./README.md ./README.md
@@ -29,18 +29,18 @@ ARG CGO_ENABLED
2929
ENV CGO_ENABLED ${CGO_ENABLED}
3030
ENV GOPATH /go
3131
ARG GOLANGCILINT_VERSION
32-
RUN go install github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCILINT_VERSION} \
32+
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg go install github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCILINT_VERSION} \
3333
&& mv /go/bin/golangci-lint /bin/golangci-lint
3434
ARG GOFUMPT_VERSION
3535
RUN go install mvdan.cc/gofumpt@${GOFUMPT_VERSION} \
3636
&& mv /go/bin/gofumpt /bin/gofumpt
37-
RUN go install golang.org/x/vuln/cmd/govulncheck@latest \
37+
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg go install golang.org/x/vuln/cmd/govulncheck@latest \
3838
&& mv /go/bin/govulncheck /bin/govulncheck
3939
ARG GOIMPORTS_VERSION
40-
RUN go install golang.org/x/tools/cmd/goimports@${GOIMPORTS_VERSION} \
40+
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg go install golang.org/x/tools/cmd/goimports@${GOIMPORTS_VERSION} \
4141
&& mv /go/bin/goimports /bin/goimports
4242
ARG DEEPCOPY_VERSION
43-
RUN go install github.com/siderolabs/deep-copy@${DEEPCOPY_VERSION} \
43+
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg go install github.com/siderolabs/deep-copy@${DEEPCOPY_VERSION} \
4444
&& mv /go/bin/deep-copy /bin/deep-copy
4545

4646
# tools and sources

Makefile

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
22
#
3-
# Generated on 2022-11-28T14:51:36Z by kres 3ac53a8.
3+
# Generated on 2023-05-11T13:47:02Z by kres latest.
44

55
# common variables
66

@@ -13,14 +13,14 @@ WITH_RACE ?= false
1313
REGISTRY ?= ghcr.io
1414
USERNAME ?= siderolabs
1515
REGISTRY_AND_USERNAME ?= $(REGISTRY)/$(USERNAME)
16-
GOLANGCILINT_VERSION ?= v1.50.1
17-
GOFUMPT_VERSION ?= v0.4.0
18-
GO_VERSION ?= 1.19
19-
GOIMPORTS_VERSION ?= v0.3.0
16+
GOLANGCILINT_VERSION ?= v1.52.2
17+
GOFUMPT_VERSION ?= v0.5.0
18+
GO_VERSION ?= 1.20
19+
GOIMPORTS_VERSION ?= v0.9.1
2020
PROTOBUF_GO_VERSION ?= 1.28.1
21-
GRPC_GO_VERSION ?= 1.2.0
22-
GRPC_GATEWAY_VERSION ?= 2.14.0
23-
VTPROTOBUF_VERSION ?= 0.3.0
21+
GRPC_GO_VERSION ?= 1.3.0
22+
GRPC_GATEWAY_VERSION ?= 2.15.2
23+
VTPROTOBUF_VERSION ?= 0.4.0
2424
DEEPCOPY_VERSION ?= v0.5.5
2525
GO_BUILDFLAGS ?=
2626
GO_LDFLAGS ?=
@@ -58,7 +58,7 @@ COMMON_ARGS += --build-arg=GRPC_GATEWAY_VERSION="$(GRPC_GATEWAY_VERSION)"
5858
COMMON_ARGS += --build-arg=VTPROTOBUF_VERSION="$(VTPROTOBUF_VERSION)"
5959
COMMON_ARGS += --build-arg=DEEPCOPY_VERSION="$(DEEPCOPY_VERSION)"
6060
COMMON_ARGS += --build-arg=TESTPKGS="$(TESTPKGS)"
61-
TOOLCHAIN ?= docker.io/golang:1.19-alpine
61+
TOOLCHAIN ?= docker.io/golang:1.20-alpine
6262

6363
# help menu
6464

containers/lazymap.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func (m *LazyBiMap[K, V]) GetOrCreate(key K) (V, error) {
2020

2121
val, err := m.Creator(key)
2222
if err != nil {
23-
return *new(V), err //nolint:gocritic
23+
return *new(V), err
2424
}
2525

2626
m.biMap.Set(key, val)
@@ -162,7 +162,7 @@ func (m *LazyMap[K, V]) GetOrCreate(key K) (V, error) {
162162

163163
val, err := m.Creator(key)
164164
if err != nil {
165-
return *new(V), err //nolint:gocritic
165+
return *new(V), err
166166
}
167167

168168
m.dataMap[key] = val

containers/map.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func (m *ConcurrentMap[K, V]) RemoveAndGet(key K) (V, bool) {
9595
defer m.mx.Unlock()
9696

9797
if m.m == nil {
98-
return *new(V), false //nolint:gocritic
98+
return *new(V), false
9999
}
100100

101101
val, ok := m.m[key]

maps/maps.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,3 +180,36 @@ func FilterInPlace[M ~map[K]V, K comparable, V any](m M, fn func(K, V) bool) M {
180180
// We return original map even if we filtered everything out unlike Filter function.
181181
return m
182182
}
183+
184+
// Clear removes all entries from m, leaving it empty.
185+
func Clear[M ~map[K]V, K comparable, V any](m M) {
186+
for k := range m {
187+
delete(m, k)
188+
}
189+
}
190+
191+
// Clone returns a copy of m. This is a shallow clone:
192+
// the new keys and values are set using ordinary assignment.
193+
func Clone[M ~map[K]V, K comparable, V any](m M) M {
194+
// Preserve nil in case it matters.
195+
if m == nil {
196+
return nil
197+
}
198+
199+
r := make(M, len(m))
200+
for k, v := range m {
201+
r[k] = v
202+
}
203+
204+
return r
205+
}
206+
207+
// Copy copies all key/value pairs in src adding them to dst.
208+
// When a key in src is already present in dst,
209+
// the value in dst will be overwritten by the value associated
210+
// with the key in src.
211+
func Copy[M1 ~map[K]V, M2 ~map[K]V, K comparable, V any](dst M1, src M2) {
212+
for k, v := range src {
213+
dst[k] = v
214+
}
215+
}

slices/slices.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,35 @@ func Copy[S ~[]V, V any](s S, n int) S {
163163

164164
return result
165165
}
166+
167+
// Clone returns a copy of the slice.
168+
// The elements are copied using assignment, so this is a shallow clone.
169+
func Clone[S ~[]E, E any](s S) S {
170+
// Preserve nil in case it matters.
171+
if s == nil {
172+
return nil
173+
}
174+
175+
return append(S([]E{}), s...)
176+
}
177+
178+
// Clip removes unused capacity from the slice, returning s[:len(s):len(s)].
179+
func Clip[S ~[]E, E any](s S) S {
180+
return s[:len(s):len(s)]
181+
}
182+
183+
// Grow increases the slice's capacity, if necessary, to guarantee space for
184+
// another n elements. After Grow(n), at least n elements can be appended
185+
// to the slice without another allocation. If n is negative or too large to
186+
// allocate the memory, Grow panics.
187+
func Grow[S ~[]E, E any](s S, n int) S {
188+
if n < 0 {
189+
panic("cannot be negative")
190+
}
191+
192+
if n -= cap(s) - len(s); n > 0 {
193+
s = append([]E(s)[:cap(s)], make([]E, n)...)[:len(s)]
194+
}
195+
196+
return s
197+
}

xerrors/xerrors_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
"github.com/siderolabs/gen/xerrors"
1515
)
1616

17-
//nolint:unused
1817
type testTag struct{}
1918

2019
func TestTagged(t *testing.T) {

0 commit comments

Comments
 (0)