Skip to content

chore: upgrade Go to 1.26 and golangci-lint to v2.10.1#7904

Open
awesomenix wants to merge 4 commits intomainfrom
chore/upgrade-go-1.26
Open

chore: upgrade Go to 1.26 and golangci-lint to v2.10.1#7904
awesomenix wants to merge 4 commits intomainfrom
chore/upgrade-go-1.26

Conversation

@awesomenix
Copy link
Contributor

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

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 go directives across all Go modules to Go 1.26.
  • Remove the toolchain directive from vhdbuilder/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]>
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]>
Copilot AI review requested due to automatic review settings February 18, 2026 23:35
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 21 out of 21 changed files in this pull request and generated no new comments.

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]>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 22 out of 22 changed files in this pull request and generated 11 comments.

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])
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
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])
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
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])
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
fmt.Fprintf(&buf, "\"%s=%t\", ", key, featureGates[key])
_, _ = fmt.Fprintf(&buf, "\"%s=%t\", ", key, featureGates[key])

Copilot uses AI. Check for mistakes.
Comment on lines 681 to 683
if !profile.Is2404VHDDistro() {
sb.WriteString(fmt.Sprintf("LimitNOFILE=%s\n", ulimitConfig.NoFile))
fmt.Fprintf(&sb, "LimitNOFILE=%s\n", ulimitConfig.NoFile)
}
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines 60 to +61
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
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
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])
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
fmt.Fprintf(&buf, "\"%s=%s\", ", key, config[key])
_, _ = fmt.Fprintf(&buf, "\"%s=%s\", ", key, config[key])

Copilot uses AI. Check for mistakes.
Comment on lines +1234 to +1235
fmt.Fprintf(&buf, "agentpool=%s", a.Name)
fmt.Fprintf(&buf, ",kubernetes.azure.com/agentpool=%s", a.Name)
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
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])
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
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])
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
fmt.Fprintf(&buf, "\"%s=%s\", ", key, kubeproxyConfig[key])
_, _ = fmt.Fprintf(&buf, "\"%s=%s\", ", key, kubeproxyConfig[key])

Copilot uses AI. Check for mistakes.
Comment on lines +676 to 677
fmt.Fprintf(&sb, "LimitMEMLOCK=%s\n", ulimitConfig.MaxLockedMemory)
}
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments