chore: upgrade Go to 1.26 and golangci-lint to v2.10.1#7904
chore: upgrade Go to 1.26 and golangci-lint to v2.10.1#7904awesomenix wants to merge 4 commits intomainfrom
Conversation
a24855f to
76fa87e
Compare
There was a problem hiding this comment.
Pull request overview
Updates the repository’s Go toolchain baseline and CI linting to a newer Go release, aligning all Go modules and GitHub Actions workflows on the same Go version and updating golangci-lint accordingly.
Changes:
- Bump
godirectives across all Go modules to Go 1.26. - Remove the
toolchaindirective fromvhdbuilder/lister/go.mod. - Update GitHub Actions workflows to use Go 1.26 and golangci-lint v2.10.1.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
go.mod |
Updates main module Go version to 1.26.0. |
e2e/go.mod |
Updates e2e module Go version to 1.26.0. |
aks-node-controller/go.mod |
Updates controller module Go version to 1.26.0. |
vhdbuilder/prefetch/go.mod |
Updates prefetch module Go version to 1.26.0. |
vhdbuilder/lister/go.mod |
Updates Go version to 1.26.0 and removes the toolchain directive. |
hack/tools/go.mod |
Updates tools module Go version to 1.26. |
hack/tools/Makefile |
Bumps GOLANGCI_LINT_VERSION to v2.10.1. |
.github/workflows/validate-components.yml |
Sets go-version: '1.26' in workflow jobs. |
.github/workflows/shellspec.yaml |
Sets go-version: '1.26'. |
.github/workflows/shellcheck.yml |
Sets go-version: '1.26'. |
.github/workflows/golangci-lint.yml |
Sets go-version: '1.26' and updates golangci-lint to v2.10.1. |
.github/workflows/go-test.yml |
Sets go-version: '1.26'. |
.github/workflows/copilot-setup-steps.yml |
Sets go-version: '1.26'. |
.github/workflows/check-coverage.yml |
Sets go-version: '1.26'. |
Update all Go modules to require Go 1.26.0 and bump golangci-lint from v2.8.0 to v2.10.1 (which adds Go 1.26 support). Changes: - Update go directive in all 6 go.mod files to go 1.26.0 - Remove obsolete toolchain directive from vhdbuilder/lister/go.mod - Update go-version in all 7 GitHub Actions workflow files - Bump golangci-lint to v2.10.1 in workflow and hack/tools/Makefile Co-authored-by: Copilot <[email protected]>
9f5df2e to
223bc7d
Compare
Fix 16 new lint issues introduced by upgrading golangci-lint to v2.10.1: - staticcheck QF1012 (11): replace WriteString(fmt.Sprintf(...)) with fmt.Fprintf(...) in baker.go, helper.go, types.go, utils.go - gosec G706/G705 (2): add nolint directives for false positive taint analysis in apiserver/getnodebootstrapdata.go - gosec G101 (1): add nolint for mock test data in mocks.go - gosec G117 (1): add nolint for Secret field name in types.go - gosec G703 (1): add nolint for internal path in component_configs.go Co-authored-by: Copilot <[email protected]>
The constant cseVariableEncodingGzip exists in baker_test.go and is not accessible from baker.go. Add nolint directive. Co-authored-by: Copilot <[email protected]>
Move the cseVariableEncoding type and cseVariableEncodingGzip constant from baker_test.go to baker.go so it can be shared. Replace all raw "gzip" string literals with the constant, resolving the goconst lint warning properly instead of suppressing it. Co-authored-by: Copilot <[email protected]>
| var buf bytes.Buffer | ||
| for _, key := range keys { | ||
| buf.WriteString(fmt.Sprintf("%s=%s ", key, k[key])) | ||
| fmt.Fprintf(&buf, "%s=%s ", key, k[key]) |
There was a problem hiding this comment.
fmt.Fprintf returns an error, and this call ignores it. With errcheck enabled in .golangci.yaml, this will be reported (even if bytes.Buffer never errors). Capture and ignore explicitly (_, _ = ...) or switch back to buf.WriteString(fmt.Sprintf(...))/manual concatenation to keep lint clean.
| var buf bytes.Buffer | ||
| for _, key := range keys { | ||
| buf.WriteString(fmt.Sprintf("%s=%s ", key, config[key])) | ||
| fmt.Fprintf(&buf, "%s=%s ", key, config[key]) |
There was a problem hiding this comment.
Same as above: fmt.Fprintf returns an error and this call ignores it; with errcheck enabled this will likely fail CI. Either explicitly discard the return values (_, _ = ...) or use an API that doesn't introduce an ignored error return.
| var buf bytes.Buffer | ||
| for _, key := range keys { | ||
| buf.WriteString(fmt.Sprintf("\"%s=%t\", ", key, featureGates[key])) | ||
| fmt.Fprintf(&buf, "\"%s=%t\", ", key, featureGates[key]) |
There was a problem hiding this comment.
fmt.Fprintf returns an error that is ignored; with errcheck enabled this is likely to be reported. Suggest explicitly discarding return values (_, _ = ...) or using WriteString(fmt.Sprintf(...)) to avoid an unchecked error path.
| fmt.Fprintf(&buf, "\"%s=%t\", ", key, featureGates[key]) | |
| _, _ = fmt.Fprintf(&buf, "\"%s=%t\", ", key, featureGates[key]) |
| if !profile.Is2404VHDDistro() { | ||
| sb.WriteString(fmt.Sprintf("LimitNOFILE=%s\n", ulimitConfig.NoFile)) | ||
| fmt.Fprintf(&sb, "LimitNOFILE=%s\n", ulimitConfig.NoFile) | ||
| } |
There was a problem hiding this comment.
fmt.Fprintf returns an error that is ignored; with errcheck enabled this is likely to be reported. Suggest explicitly discarding (_, _ = ...) or using sb.WriteString/formatting without an error return.
| w.WriteHeader(http.StatusOK) | ||
| fmt.Fprint(w, string(result)) | ||
| fmt.Fprint(w, string(result)) //nolint:gosec // result is JSON-marshalled struct, not raw user input |
There was a problem hiding this comment.
fmt.Fprint returns an error but it’s ignored here, and the suppression is for gosec rather than errcheck. Prefer writing the bytes directly and handling (or explicitly discarding) the returned error; if you intentionally ignore it, use the correct linter suppression (errcheck) with an explanation.
| var buf bytes.Buffer | ||
| for _, key := range keys { | ||
| buf.WriteString(fmt.Sprintf("\"%s=%s\", ", key, config[key])) | ||
| fmt.Fprintf(&buf, "\"%s=%s\", ", key, config[key]) |
There was a problem hiding this comment.
fmt.Fprintf returns an error that is ignored here. Since errcheck is enabled for non-test code, this pattern will likely be flagged. Consider explicitly discarding (_, _ = ...) or using WriteString/WriteRune to avoid introducing an error return.
| fmt.Fprintf(&buf, "\"%s=%s\", ", key, config[key]) | |
| _, _ = fmt.Fprintf(&buf, "\"%s=%s\", ", key, config[key]) |
| fmt.Fprintf(&buf, "agentpool=%s", a.Name) | ||
| fmt.Fprintf(&buf, ",kubernetes.azure.com/agentpool=%s", a.Name) |
There was a problem hiding this comment.
These fmt.Fprintf calls ignore the returned error; with errcheck enabled this will likely be flagged. Since the target is a bytes.Buffer, either explicitly discard return values (_, _ = ...) or switch back to WriteString to avoid introducing an unchecked error return (and apply the same pattern to the later fmt.Fprintf in this function).
| var buf bytes.Buffer | ||
| for _, key := range keys { | ||
| buf.WriteString(fmt.Sprintf("\"%s=%s\", ", key, kubeletConfig[key])) | ||
| fmt.Fprintf(&buf, "\"%s=%s\", ", key, kubeletConfig[key]) |
There was a problem hiding this comment.
fmt.Fprintf returns an error that is ignored here; with errcheck enabled this is likely to fail lint. Consider explicitly discarding return values (_, _ = ...) or using WriteString/Sprintf as before.
| var buf bytes.Buffer | ||
| for _, key := range keys { | ||
| buf.WriteString(fmt.Sprintf("\"%s=%s\", ", key, kubeproxyConfig[key])) | ||
| fmt.Fprintf(&buf, "\"%s=%s\", ", key, kubeproxyConfig[key]) |
There was a problem hiding this comment.
Same issue: fmt.Fprintf returns an error but it's ignored; errcheck is enabled for this repo. Either explicitly discard (_, _ = ...) or use an alternative that doesn't introduce an unchecked error.
| fmt.Fprintf(&buf, "\"%s=%s\", ", key, kubeproxyConfig[key]) | |
| _, _ = fmt.Fprintf(&buf, "\"%s=%s\", ", key, kubeproxyConfig[key]) |
| fmt.Fprintf(&sb, "LimitMEMLOCK=%s\n", ulimitConfig.MaxLockedMemory) | ||
| } |
There was a problem hiding this comment.
fmt.Fprintf returns an error; ignoring it here will likely be flagged by errcheck. Since strings.Builder writes don't error, explicitly discard return values (_, _ = ...) or use sb.WriteString to avoid introducing an ignored error return.
Update all Go modules to require Go 1.26.0 and bump golangci-lint from v2.8.0 to v2.10.1 (which adds Go 1.26 support).
Changes: