Skip to content

Commit edb0d82

Browse files
chore: go1.23.1 golangci lint 1.6.1 (#3940)
# Summary Followup to slsa-framework/slsa-verifier#810 - upgrades to go 1.23.1 and golangci-lint 1.6.1 - makes necessary changes for the linter - as of go 1.22, no need to make a copy of the loop variable - change non-string use of `fmt.Errorf(err)` to `fmt.Error(err)` ## Testing Process unit tests continue to pass, as well as the linter ## Checklist - [x] Review the contributing [guidelines](https://github.com/slsa-framework/slsa-github-generator/blob/main/CONTRIBUTING.md) - [x] Add a reference to related issues in the PR description. - [x] Update documentation if applicable. - [x] Add unit tests if applicable. - [x] Add changes to the [CHANGELOG](https://github.com/slsa-framework/slsa-github-generator/blob/main/CHANGELOG.md) if applicable. --------- Signed-off-by: Ramon Petgrave <[email protected]>
1 parent 22646f3 commit edb0d82

File tree

14 files changed

+30
-49
lines changed

14 files changed

+30
-49
lines changed

.github/workflows/pre-submit.lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ jobs:
8787
with:
8888
go-version-file: "go.mod"
8989
- env:
90-
GOLANGCI_LINT_VERSION: "1.57.0"
91-
GOLANGCI_LINT_CHECKSUM: "fc7a9f73d2e3de6aa0ef8d8586906e0067fed577f704b3b0bc29cdd6ad0b74d8"
90+
GOLANGCI_LINT_VERSION: "1.61.0"
91+
GOLANGCI_LINT_CHECKSUM: "77cb0af99379d9a21d5dc8c38364d060e864a01bd2f3e30b5e8cc550c3a54111"
9292
run: |
9393
set -euo pipefail
9494

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ linters:
4545
# TODO(github.com/slsa-framework/slsa-github-generator/issues/450): enable errorlint
4646
# - errorlint
4747
- exhaustive
48-
- exportloopref
48+
- copyloopvar
4949
# TODO(github.com/slsa-framework/slsa-github-generator/issues/450): enable gci
5050
# - gci
5151
- gochecknoinits

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/slsa-framework/slsa-github-generator
22

3-
go 1.21
3+
go 1.23.1
44

55
require (
66
github.com/coreos/go-oidc/v3 v3.10.0

internal/builders/docker/pkg/builder_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func Test_CreateBuildDefinition(t *testing.T) {
5353
}
5454

5555
if diff := cmp.Diff(got, want); diff != "" {
56-
t.Errorf(diff)
56+
t.Error(diff)
5757
}
5858
}
5959

@@ -206,7 +206,7 @@ func Test_inspectArtifacts(t *testing.T) {
206206
want := []intoto.Subject{s1, s2, s3, s4}
207207

208208
if diff := cmp.Diff(got, want); diff != "" {
209-
t.Errorf(diff)
209+
t.Error(diff)
210210
}
211211
}
212212

@@ -256,7 +256,7 @@ func Test_inspectArtifactsNoRoot(t *testing.T) {
256256
want := []intoto.Subject{s1, s2, s3, s4}
257257

258258
if diff := cmp.Diff(got, want); diff != "" {
259-
t.Errorf(diff)
259+
t.Error(diff)
260260
}
261261
}
262262

@@ -317,7 +317,7 @@ func Test_ParseProvenance(t *testing.T) {
317317
}
318318

319319
if diff := cmp.Diff(got, want); diff != "" {
320-
t.Errorf(diff)
320+
t.Error(diff)
321321
}
322322
}
323323

@@ -345,7 +345,7 @@ func Test_ProvenanceStatementSLSA1_ToDockerBuildConfig(t *testing.T) {
345345
ForceCheckout: true,
346346
}
347347
if diff := cmp.Diff(got, want); diff != "" {
348-
t.Errorf(diff)
348+
t.Error(diff)
349349
}
350350
}
351351

internal/builders/docker/pkg/common_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func Test_BuildDefinition(t *testing.T) {
6262
}
6363

6464
if diff := cmp.Diff(got, want); diff != "" {
65-
t.Errorf(diff)
65+
t.Error(diff)
6666
}
6767
}
6868

internal/builders/docker/pkg/config_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func Test_LoadBuildConfigFromFile(t *testing.T) {
5252
}
5353

5454
if diff := cmp.Diff(got, want); diff != "" {
55-
t.Errorf(diff)
55+
t.Error(diff)
5656
}
5757
}
5858

@@ -85,6 +85,6 @@ func Test_NewDockerBuildConfig(t *testing.T) {
8585
}
8686

8787
if diff := cmp.Diff(got, want); diff != "" {
88-
t.Errorf(diff)
88+
t.Error(diff)
8989
}
9090
}

internal/builders/go/e2e-presubmits/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module slsa-framework/example-package
22

3-
go 1.21
3+
go 1.23.1
44

55
require github.com/pborman/uuid v1.2.1
66

internal/builders/go/main_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func checkWorkingDir(t *testing.T, wd, expected string) {
4646
}
4747

4848
if expectedWd != wd {
49-
t.Errorf(cmp.Diff(wd, expectedWd))
49+
t.Error(cmp.Diff(wd, expectedWd))
5050
}
5151
}
5252

@@ -298,7 +298,6 @@ func Test_runBuild(t *testing.T) {
298298
}
299299

300300
for _, tt := range tests {
301-
tt := tt // Re-initializing variable so it is not changed while executing the closure below
302301
t.Run(tt.name, func(t *testing.T) {
303302
// *** WARNING: do not enable t.Parallel(), because we're writing to environment variables ***.
304303
file, err := os.CreateTemp("", "")
@@ -336,19 +335,19 @@ func Test_runBuild(t *testing.T) {
336335
}
337336

338337
if !cmp.Equal(subject, tt.subject) {
339-
t.Errorf(cmp.Diff(subject, tt.subject))
338+
t.Error(cmp.Diff(subject, tt.subject))
340339
}
341340

342341
commands := append([]string{goc, "build", "-mod=vendor"}, tt.commands...)
343342
if !cmp.Equal(cmd, commands) {
344-
t.Errorf(cmp.Diff(cmd, commands))
343+
t.Error(cmp.Diff(cmd, commands))
345344
}
346345

347346
checkWorkingDir(t, wd, tt.workingDir)
348347

349348
sorted := cmpopts.SortSlices(func(a, b string) bool { return a < b })
350349
if !cmp.Equal(env, tt.envs, sorted) {
351-
t.Errorf(cmp.Diff(env, tt.envs))
350+
t.Error(cmp.Diff(env, tt.envs))
352351
}
353352
})
354353
}

internal/builders/go/pkg/build_test.go

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,12 @@ func Test_isAllowedEnvVariable(t *testing.T) {
9090
},
9191
}
9292
for _, tt := range tests {
93-
tt := tt // Re-initializing variable so it is not changed while executing the closure below
9493
t.Run(tt.name, func(t *testing.T) {
9594
t.Parallel()
9695

9796
r := isAllowedEnvVariable(tt.variable)
9897
if !cmp.Equal(r, tt.expected) {
99-
t.Errorf(cmp.Diff(r, tt.expected))
98+
t.Error(cmp.Diff(r, tt.expected))
10099
}
101100
})
102101
}
@@ -126,7 +125,6 @@ func Test_getOutputBinaryPath(t *testing.T) {
126125
},
127126
}
128127
for _, tt := range tests {
129-
tt := tt // Re-initializing variable so it is not changed while executing the closure below
130128
t.Run(tt.name, func(t *testing.T) {
131129
t.Parallel()
132130

@@ -140,7 +138,7 @@ func Test_getOutputBinaryPath(t *testing.T) {
140138
}
141139

142140
if !cmp.Equal(r, tt.path) {
143-
t.Errorf(cmp.Diff(r, tt.path))
141+
t.Error(cmp.Diff(r, tt.path))
144142
}
145143
})
146144
}
@@ -177,13 +175,12 @@ func Test_isAllowedArg(t *testing.T) {
177175
})
178176
}
179177
for _, tt := range tests {
180-
tt := tt // Re-initializing variable so it is not changed while executing the closure below
181178
t.Run(tt.name, func(t *testing.T) {
182179
t.Parallel()
183180

184181
r := isAllowedArg(tt.argument)
185182
if !cmp.Equal(r, tt.expected) {
186-
t.Errorf(cmp.Diff(r, tt.expected))
183+
t.Error(cmp.Diff(r, tt.expected))
187184
}
188185
})
189186
}
@@ -442,7 +439,6 @@ func Test_generateOutputFilename(t *testing.T) {
442439
}
443440

444441
for _, tt := range tests {
445-
tt := tt // Re-initializing variable so it is not changed while executing the closure below
446442
t.Run(tt.name, func(t *testing.T) {
447443
// Note: disable parallelism to avoid env variable clobbering between tests.
448444
// t.Parallel()
@@ -491,7 +487,7 @@ func Test_generateOutputFilename(t *testing.T) {
491487
}
492488

493489
if fn != tt.expected.fn {
494-
t.Errorf(cmp.Diff(fn, tt.expected.fn))
490+
t.Error(cmp.Diff(fn, tt.expected.fn))
495491
}
496492
})
497493
}
@@ -595,7 +591,6 @@ func Test_SetArgEnvVariables(t *testing.T) {
595591
}
596592

597593
for _, tt := range tests {
598-
tt := tt // Re-initializing variable so it is not changed while executing the closure below
599594
t.Run(tt.name, func(t *testing.T) {
600595
t.Parallel()
601596

@@ -619,7 +614,7 @@ func Test_SetArgEnvVariables(t *testing.T) {
619614

620615
sorted := cmpopts.SortSlices(func(a, b string) bool { return a < b })
621616
if !cmp.Equal(b.argEnv, tt.expected.env, sorted) {
622-
t.Errorf(cmp.Diff(b.argEnv, tt.expected.env))
617+
t.Error(cmp.Diff(b.argEnv, tt.expected.env))
623618
}
624619
})
625620
}
@@ -704,7 +699,6 @@ func Test_generateEnvVariables(t *testing.T) {
704699
}
705700

706701
for _, tt := range tests {
707-
tt := tt // Re-initializing variable so it is not changed while executing the closure below
708702
t.Run(tt.name, func(t *testing.T) {
709703
t.Parallel()
710704

@@ -731,7 +725,7 @@ func Test_generateEnvVariables(t *testing.T) {
731725
expectedFlags := tt.expected.flags
732726
sorted := cmpopts.SortSlices(func(a, b string) bool { return a < b })
733727
if !cmp.Equal(flags, expectedFlags, sorted) {
734-
t.Errorf(cmp.Diff(flags, expectedFlags))
728+
t.Error(cmp.Diff(flags, expectedFlags))
735729
}
736730
})
737731
}
@@ -862,7 +856,6 @@ func Test_generateLdflags(t *testing.T) {
862856
}
863857

864858
for _, tt := range tests {
865-
tt := tt // Re-initializing variable so it is not changed while executing the closure below
866859
t.Run(tt.name, func(t *testing.T) {
867860
// Disable to avoid env clobbering between tests.
868861
// t.Parallel()
@@ -905,7 +898,7 @@ func Test_generateLdflags(t *testing.T) {
905898
}
906899
// Note: generated env variables contain the process's env variables too.
907900
if !cmp.Equal(ldflags, tt.outldflags) {
908-
t.Errorf(cmp.Diff(ldflags, tt.outldflags))
901+
t.Error(cmp.Diff(ldflags, tt.outldflags))
909902
}
910903
})
911904
}
@@ -954,7 +947,6 @@ func Test_generateFlags(t *testing.T) {
954947
}
955948

956949
for _, tt := range tests {
957-
tt := tt // Re-initializing variable so it is not changed while executing the closure below
958950
t.Run(tt.name, func(t *testing.T) {
959951
t.Parallel()
960952

@@ -980,7 +972,7 @@ func Test_generateFlags(t *testing.T) {
980972
// Note: generated env variables contain the process's env variables too.
981973
sorted := cmpopts.SortSlices(func(a, b string) bool { return a < b })
982974
if !cmp.Equal(flags, expectedFlags, sorted) {
983-
t.Errorf(cmp.Diff(flags, expectedFlags))
975+
t.Error(cmp.Diff(flags, expectedFlags))
984976
}
985977
})
986978
}
@@ -1024,7 +1016,6 @@ func Test_generateCommand(t *testing.T) {
10241016
}
10251017

10261018
for _, tt := range tests {
1027-
tt := tt // Re-initializing variable so it is not changed while executing the closure below
10281019
t.Run(tt.name, func(t *testing.T) {
10291020
t.Parallel()
10301021

@@ -1056,7 +1047,7 @@ func Test_generateCommand(t *testing.T) {
10561047

10571048
sorted := cmpopts.SortSlices(func(a, b string) bool { return a < b })
10581049
if !cmp.Equal(command, expectedCommand, sorted) {
1059-
t.Errorf(cmp.Diff(command, expectedCommand))
1050+
t.Error(cmp.Diff(command, expectedCommand))
10601051
}
10611052
}
10621053
})

internal/builders/go/pkg/config_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ func Test_ConfigFromFile(t *testing.T) {
185185
},
186186
}
187187
for _, tt := range tests {
188-
tt := tt // Re-initializing variable so it is not changed while executing the closure below
189188
t.Run(tt.name, func(t *testing.T) {
190189
t.Parallel()
191190

@@ -199,7 +198,7 @@ func Test_ConfigFromFile(t *testing.T) {
199198
}
200199

201200
if !cmp.Equal(*cfg, tt.config) {
202-
t.Errorf(cmp.Diff(*cfg, tt.config))
201+
t.Error(cmp.Diff(*cfg, tt.config))
203202
}
204203
})
205204
}

0 commit comments

Comments
 (0)