Skip to content

Commit 3f0aec1

Browse files
authored
Merge pull request #3182 from crazy-max/go-1.24
update to go 1.24
2 parents 03f9877 + 1383aa3 commit 3f0aec1

35 files changed

+26
-62
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ env:
3636
TEST_CACHE_SCOPE: "test"
3737
TESTFLAGS: "-v --parallel=6 --timeout=30m"
3838
GOTESTSUM_FORMAT: "standard-verbose"
39-
GO_VERSION: "1.23"
40-
GOTESTSUM_VERSION: "v1.9.0" # same as one in Dockerfile
39+
GO_VERSION: "1.24"
40+
GOTESTSUM_VERSION: "v1.12.0" # same as one in Dockerfile
4141

4242
jobs:
4343
test-integration:

.github/workflows/codeql.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ on:
1717
pull_request:
1818

1919
env:
20-
GO_VERSION: "1.23"
20+
GO_VERSION: "1.24"
2121

2222
jobs:
2323
codeql:

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# syntax=docker/dockerfile:1
22

3-
ARG GO_VERSION=1.23
3+
ARG GO_VERSION=1.24
44
ARG ALPINE_VERSION=3.21
55
ARG XX_VERSION=1.6.1
66

bake/bake.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -483,8 +483,7 @@ func (c Config) expandTargets(pattern string) ([]string, error) {
483483
func (c Config) loadLinks(name string, t *Target, m map[string]*Target, o map[string]map[string]Override, visited []string, ent *EntitlementConf) error {
484484
visited = append(visited, name)
485485
for _, v := range t.Contexts {
486-
if strings.HasPrefix(v, "target:") {
487-
target := strings.TrimPrefix(v, "target:")
486+
if target, ok := strings.CutPrefix(v, "target:"); ok {
488487
if target == name {
489488
return errors.Errorf("target %s cannot link to itself", target)
490489
}
@@ -1275,8 +1274,8 @@ func collectLocalPaths(t build.Inputs) []string {
12751274
if v, ok := isLocalPath(t.DockerfilePath); ok {
12761275
out = append(out, v)
12771276
}
1278-
} else if strings.HasPrefix(t.ContextPath, "cwd://") {
1279-
out = append(out, strings.TrimPrefix(t.ContextPath, "cwd://"))
1277+
} else if v, ok := strings.CutPrefix(t.ContextPath, "cwd://"); ok {
1278+
out = append(out, v)
12801279
}
12811280
for _, v := range t.NamedContexts {
12821281
if v.State != nil {
@@ -1328,11 +1327,11 @@ func toBuildOpt(t *Target, inp *Input) (*build.Options, error) {
13281327
bi.DockerfileInline = *t.DockerfileInline
13291328
}
13301329
updateContext(&bi, inp)
1331-
if strings.HasPrefix(bi.DockerfilePath, "cwd://") {
1330+
if v, ok := strings.CutPrefix(bi.DockerfilePath, "cwd://"); ok {
13321331
// If Dockerfile is local for a remote invocation, we first check if
13331332
// it's not outside the working directory and then resolve it to an
13341333
// absolute path.
1335-
bi.DockerfilePath = path.Clean(strings.TrimPrefix(bi.DockerfilePath, "cwd://"))
1334+
bi.DockerfilePath = path.Clean(v)
13361335
var err error
13371336
bi.DockerfilePath, err = filepath.Abs(bi.DockerfilePath)
13381337
if err != nil {
@@ -1357,15 +1356,15 @@ func toBuildOpt(t *Target, inp *Input) (*build.Options, error) {
13571356
return nil, errors.Errorf("reading a dockerfile for a remote build invocation is currently not supported")
13581357
}
13591358
}
1360-
if strings.HasPrefix(bi.ContextPath, "cwd://") {
1361-
bi.ContextPath = path.Clean(strings.TrimPrefix(bi.ContextPath, "cwd://"))
1359+
if v, ok := strings.CutPrefix(bi.ContextPath, "cwd://"); ok {
1360+
bi.ContextPath = path.Clean(v)
13621361
}
13631362
if !build.IsRemoteURL(bi.ContextPath) && bi.ContextState == nil && !filepath.IsAbs(bi.DockerfilePath) {
13641363
bi.DockerfilePath = filepath.Join(bi.ContextPath, bi.DockerfilePath)
13651364
}
13661365
for k, v := range bi.NamedContexts {
1367-
if strings.HasPrefix(v.Path, "cwd://") {
1368-
bi.NamedContexts[k] = build.NamedContext{Path: path.Clean(strings.TrimPrefix(v.Path, "cwd://"))}
1366+
if v, ok := strings.CutPrefix(v.Path, "cwd://"); ok {
1367+
bi.NamedContexts[k] = build.NamedContext{Path: path.Clean(v)}
13691368
}
13701369
}
13711370

bake/bake_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,7 +1381,6 @@ target "d" {
13811381
},
13821382
}
13831383
for _, tt := range cases {
1384-
tt := tt
13851384
t.Run(tt.name, func(t *testing.T) {
13861385
m, g, err := ReadTargets(ctx, []File{f}, []string{"d"}, tt.overrides, nil, &EntitlementConf{})
13871386
require.NoError(t, err)
@@ -1454,7 +1453,6 @@ group "default" {
14541453
},
14551454
}
14561455
for _, tt := range cases {
1457-
tt := tt
14581456
t.Run(tt.name, func(t *testing.T) {
14591457
m, g, err := ReadTargets(ctx, []File{f}, []string{"default"}, tt.overrides, nil, &EntitlementConf{})
14601458
require.NoError(t, err)
@@ -1509,7 +1507,6 @@ func TestTargetName(t *testing.T) {
15091507
},
15101508
}
15111509
for _, tt := range cases {
1512-
tt := tt
15131510
t.Run(tt.target, func(t *testing.T) {
15141511
_, _, err := ReadTargets(ctx, []File{{
15151512
Name: "docker-bake.hcl",
@@ -1600,7 +1597,6 @@ target "f" {
16001597
},
16011598
}
16021599
for _, tt := range cases {
1603-
tt := tt
16041600
t.Run(strings.Join(tt.names, "+"), func(t *testing.T) {
16051601
m, g, err := ReadTargets(ctx, []File{f}, tt.names, nil, nil, &EntitlementConf{})
16061602
require.NoError(t, err)

bake/compose.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ func ParseCompose(cfgs []composetypes.ConfigFile, envs map[string]string) (*Conf
6262
g := &Group{Name: "default"}
6363

6464
for _, s := range cfg.Services {
65-
s := s
6665
if s.Build == nil {
6766
continue
6867
}
@@ -144,7 +143,6 @@ func ParseCompose(cfgs []composetypes.ConfigFile, envs map[string]string) (*Conf
144143
// compose does not support nil values for labels
145144
labels := map[string]*string{}
146145
for k, v := range s.Build.Labels {
147-
v := v
148146
labels[k] = &v
149147
}
150148

bake/compose_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,6 @@ func TestServiceName(t *testing.T) {
518518
},
519519
}
520520
for _, tt := range cases {
521-
tt := tt
522521
t.Run(tt.svc, func(t *testing.T) {
523522
_, err := ParseCompose([]composetypes.ConfigFile{{Content: []byte(`
524523
services:
@@ -589,7 +588,6 @@ services:
589588
},
590589
}
591590
for _, tt := range cases {
592-
tt := tt
593591
t.Run(tt.name, func(t *testing.T) {
594592
_, err := ParseCompose([]composetypes.ConfigFile{{Content: tt.dt}}, nil)
595593
if tt.wantErr {
@@ -665,7 +663,6 @@ target "default" {
665663
},
666664
}
667665
for _, tt := range cases {
668-
tt := tt
669666
t.Run(tt.name, func(t *testing.T) {
670667
isCompose, err := validateComposeFile(tt.dt, tt.fn)
671668
assert.Equal(t, tt.isCompose, isCompose)

bake/hclparser/hclparser.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,6 @@ func Parse(b hcl.Body, opt Opt, val any) (*ParseMeta, hcl.Diagnostics) {
781781
}
782782

783783
for _, a := range content.Attributes {
784-
a := a
785784
return nil, hcl.Diagnostics{
786785
&hcl.Diagnostic{
787786
Severity: hcl.DiagError,
@@ -834,7 +833,6 @@ func Parse(b hcl.Body, opt Opt, val any) (*ParseMeta, hcl.Diagnostics) {
834833
context = subject
835834
} else {
836835
for _, block := range blocks.Blocks {
837-
block := block
838836
if block.Type == "function" && len(block.Labels) == 1 && block.Labels[0] == k {
839837
subject = block.LabelRanges[0].Ptr()
840838
context = block.DefRange.Ptr()
@@ -903,7 +901,6 @@ func Parse(b hcl.Body, opt Opt, val any) (*ParseMeta, hcl.Diagnostics) {
903901

904902
diags = hcl.Diagnostics{}
905903
for _, b := range content.Blocks {
906-
b := b
907904
v := reflect.ValueOf(val)
908905

909906
err := p.resolveBlock(b, nil)

build/build.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,6 @@ func BuildWithResultHandler(ctx context.Context, nodes []builder.Node, opts map[
383383
wg.Add(1)
384384
sharedSessionsWG[node.Name] = wg
385385
for _, s := range sessions {
386-
s := s
387386
eg.Go(func() error {
388387
return s.Run(baseCtx, c.Dialer())
389388
})

build/git_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ func TestGetGitAttributes(t *testing.T) {
109109
},
110110
}
111111
for _, tt := range cases {
112-
tt := tt
113112
t.Run(tt.name, func(t *testing.T) {
114113
setupTest(t)
115114
if tt.envGitLabels != "" {

build/opt.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,7 @@ func loadInputs(ctx context.Context, d *driver.DriverHandle, inp *Inputs, pw pro
503503
}
504504

505505
// handle OCI layout
506-
if strings.HasPrefix(v.Path, "oci-layout://") {
507-
localPath := strings.TrimPrefix(v.Path, "oci-layout://")
506+
if localPath, ok := strings.CutPrefix(v.Path, "oci-layout://"); ok {
508507
localPath, dig, hasDigest := strings.Cut(localPath, "@")
509508
localPath, tag, hasTag := strings.Cut(localPath, ":")
510509
if !hasTag {

build/provenance.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ func fetchProvenance(ctx context.Context, c *client.Client, ref string, mode con
9292
})
9393
} else if ev.Record.Results != nil {
9494
for platform, res := range ev.Record.Results {
95-
platform := platform
9695
desc := lookupProvenance(res)
9796
if desc == nil {
9897
continue

build/utils_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ func TestToBuildkitExtraHosts(t *testing.T) {
130130
}
131131

132132
for _, tc := range tests {
133-
tc := tc
134133
if tc.expectedOut == "" {
135134
tc.expectedOut = strings.Join(tc.input, ",")
136135
}

builder/builder_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ foo = "bar"
190190
},
191191
}
192192
for _, tt := range testCases {
193-
tt := tt
194193
t.Run(tt.name, func(t *testing.T) {
195194
flags, err := parseBuildkitdFlags(tt.flags, tt.driver, tt.driverOpts, tt.buildkitdConfigFile)
196195
if tt.wantErr {

commands/bake.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,8 +559,7 @@ func readBakeFiles(ctx context.Context, nodes []builder.Node, url string, names
559559
var rnames []string // remote
560560
var anames []string // both
561561
for _, v := range names {
562-
if strings.HasPrefix(v, "cwd://") {
563-
tname := strings.TrimPrefix(v, "cwd://")
562+
if tname, ok := strings.CutPrefix(v, "cwd://"); ok {
564563
lnames = append(lnames, tname)
565564
anames = append(anames, tname)
566565
} else {

commands/history/inspect.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -869,9 +869,9 @@ func printTable(w io.Writer, kvs []keyValueOutput, title string) {
869869
func readKeyValues(attrs map[string]string, prefix string) []keyValueOutput {
870870
var out []keyValueOutput
871871
for k, v := range attrs {
872-
if strings.HasPrefix(k, prefix) {
872+
if name, ok := strings.CutPrefix(k, prefix); ok {
873873
out = append(out, keyValueOutput{
874-
Name: strings.TrimPrefix(k, prefix),
874+
Name: name,
875875
Value: v,
876876
})
877877
}

commands/history/rm.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ func runRm(ctx context.Context, dockerCli command.Cli, opts rmOptions) error {
4343

4444
eg, ctx := errgroup.WithContext(ctx)
4545
for i, node := range nodes {
46-
node := node
4746
eg.Go(func() error {
4847
if node.Driver == nil {
4948
return nil

commands/history/utils.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ func queryRecords(ctx context.Context, ref string, nodes []builder.Node, opts *q
139139

140140
eg, ctx := errgroup.WithContext(ctx)
141141
for _, node := range nodes {
142-
node := node
143142
eg.Go(func() error {
144143
if node.Driver == nil {
145144
return nil

commands/imagetools/create.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ func runCreate(ctx context.Context, dockerCli command.Cli, in createOptions, arg
184184
pw := progress.WithPrefix(printer, "internal", true)
185185

186186
for _, t := range tags {
187-
t := t
188187
eg.Go(func() error {
189188
return progress.Wrap(fmt.Sprintf("pushing %s", t.String()), pw.Write, func(sub progress.SubLogger) error {
190189
eg2, _ := errgroup.WithContext(ctx)

commands/ls_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ func TestTruncPlatforms(t *testing.T) {
164164
},
165165
}
166166
for _, tt := range tests {
167-
tt := tt
168167
t.Run(tt.name, func(t *testing.T) {
169168
tpfs := truncPlatforms(tt.platforms, tt.max)
170169
assert.Equal(t, tt.expectedList, tpfs.List())

controller/build/options.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,8 @@ func ResolveOptionPaths(options *Options) (_ *Options, err error) {
7070
for k, v := range options.NamedContexts {
7171
if isRemoteURL(v) || strings.HasPrefix(v, "docker-image://") {
7272
// url prefix, this is a remote path
73-
} else if strings.HasPrefix(v, "oci-layout://") {
73+
} else if p, ok := strings.CutPrefix(v, "oci-layout://"); ok {
7474
// oci layout prefix, this is a local path
75-
p := strings.TrimPrefix(v, "oci-layout://")
7675
p, err = filepath.Abs(p)
7776
if err != nil {
7877
return nil, err

controller/build/options_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ func TestResolvePaths(t *testing.T) {
240240
},
241241
}
242242
for _, tt := range tests {
243-
tt := tt
244243
t.Run(tt.name, func(t *testing.T) {
245244
got, err := ResolveOptionPaths(tt.options)
246245
require.NoError(t, err)

driver/docker/version_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99

1010
func TestConstraint(t *testing.T) {
1111
for _, tt := range mobyBuildkitVersions {
12-
tt := tt
1312
t.Run(tt.MobyVersionConstraint, func(t *testing.T) {
1413
_, err := semver.NewConstraint(tt.MobyVersionConstraint)
1514
require.NoError(t, err)
@@ -121,7 +120,6 @@ func TestResolveBuildKitVersion(t *testing.T) {
121120
},
122121
}
123122
for _, tt := range cases {
124-
tt := tt
125123
t.Run(tt.mobyVersion, func(t *testing.T) {
126124
bkVersion, err := resolveBuildKitVersion(tt.mobyVersion)
127125
if tt.err {

hack/dockerfiles/docs.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# syntax=docker/dockerfile:1
22

3-
ARG GO_VERSION=1.23
3+
ARG GO_VERSION=1.24
44
ARG ALPINE_VERSION=3.21
55

66
ARG FORMATS=md,yaml

hack/dockerfiles/generated-files.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Copyright The Buildx Authors.
66
# Licensed under the Apache License, Version 2.0
77

8-
ARG GO_VERSION=1.23
8+
ARG GO_VERSION=1.24
99
ARG PROTOC_VERSION=3.11.4
1010
ARG PROTOC_GOOGLEAPIS_VERSION=2af421884dd468d565137215c946ebe4e245ae26
1111

hack/dockerfiles/govulncheck.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# syntax=docker/dockerfile:1
22

3-
ARG GO_VERSION=1.23
3+
ARG GO_VERSION=1.24
44
ARG ALPINE_VERSION=3.21
55

66
ARG GOVULNCHECK_VERSION=v1.1.3

hack/dockerfiles/lint.Dockerfile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
# syntax=docker/dockerfile:1
22

3-
ARG GO_VERSION=1.23
3+
ARG GO_VERSION=1.24
44
ARG ALPINE_VERSION=3.21
55
ARG XX_VERSION=1.6.1
66

77
ARG GOLANGCI_LINT_VERSION=v2.1.5
88
ARG GOLANGCI_FROM_SOURCE=false
9-
# v0.31 requires go1.24
10-
ARG GOPLS_VERSION=v0.30.0
11-
# disabled: deprecated unusedvariable simplifyrange
12-
ARG GOPLS_ANALYZERS="embeddirective fillreturns hostport infertypeargs modernize nonewvars noresultvalues simplifycompositelit simplifyslice unusedparams yield"
9+
ARG GOPLS_VERSION=v0.33.0
10+
# GOPLS_ANALYZERS defines gopls analyzers to be run. disabled by default: deprecated simplifyrange unusedfunc unusedvariable
11+
ARG GOPLS_ANALYZERS="embeddirective fillreturns infertypeargs maprange modernize nonewvars noresultvalues simplifycompositelit simplifyslice unusedparams yield"
1312

1413
FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
1514

hack/dockerfiles/vendor.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# syntax=docker/dockerfile:1
22

3-
ARG GO_VERSION=1.23
3+
ARG GO_VERSION=1.24
44
ARG ALPINE_VERSION=3.21
55

66
ARG MODOUTDATED_VERSION=v0.9.0

tests/ls.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ func testLs(t *testing.T, sb integration.Sandbox) {
3636

3737
sbDriver, _, _ := driverName(sb.Name())
3838
for _, tt := range tests {
39-
tt := tt
4039
t.Run(tt.name, func(t *testing.T) {
4140
out, err := lsCmd(sb, withArgs(tt.args...))
4241
require.NoError(t, err, out)

util/confutil/config_unix_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ func TestIsSubPath(t *testing.T) {
4949
},
5050
}
5151
for _, tt := range tests {
52-
tt := tt
5352
t.Run(tt.name, func(t *testing.T) {
5453
ok, err := isSubPath(tt.basePath, tt.subPath)
5554
require.NoError(t, err)

util/dockerutil/progress.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ func fromReader(l progress.SubLogger, rc io.ReadCloser) error {
1717

1818
defer func() {
1919
for _, st := range started {
20-
st := st
2120
if st.Completed == nil {
2221
now := time.Now()
2322
st.Completed = &now

0 commit comments

Comments
 (0)