Skip to content

Require Go 1.26 and lint with golangci-lint v2 - #169

Merged
larsxschneider merged 3 commits into
masterfrom
ls/golangci-lint-v2
Nov 27, 2026
Merged

larsxschneider merged 3 commits into
masterfrom
ls/golangci-lint-v2

Conversation

@larsxschneider

@larsxschneider larsxschneider commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

Raise the go directive in go.mod from 1.17 to 1.26 and move lint.yml from golangci-lint 1.43.0 (Go 1.17) to golangci-lint 2.15.0 (Go 1.27.4). Follow-up to #167.

Why

  • go 1.17 has been unsupported for years (Unsupported language version #166).
  • go 1.26 is the oldest supported release.
  • golangci-lint 1.43.0 can't lint code that requires a newer Go release, so the linter upgrade has to come with the go.mod change.

Changes

The .golangci.toml was ported to the v2 format via Copilot. Is uses the same linters and settings, except:

  • deadcode, structcheck, varcheck, exportloopref and typecheck no longer exist in v2. unused covers the first three; exportloopref is obsolete since Go 1.22 loop variable semantics.
  • errcheck: v2 dropped the v1 default ignore = "fmt:.*", so fmt.Fprint, fmt.Fprintf and fmt.Fprintln are now listed in exclude-functions.
  • noctx: the new exec.Command check is excluded. Passing a context to all git commands is a separate change.
  • staticcheck now includes the former stylecheck (ST*) and quickfix (QF*) checks, which v1 did not run. They stay enabled. Their findings are fixed in the second commit.

Refs #166

larsxschneider and others added 2 commits November 27, 2026 11:00
Since Go 1.19, gofmt normalizes doc comments: code blocks use a
single tab and list items use "  - ". Apply that formatting so that
newer gofmt versions leave the files unchanged.

Refs #166

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: d5946d63-5054-4db7-8484-2db48414dc6e
Newer staticcheck releases report these patterns:

* ST1006: omit unused `_` receiver names
* ST1023: drop the redundant type in `nameStyle`'s declaration
* QF1001: apply De Morgan's law to the JSON version checks
* QF1002: use a tagged switch on the file mode

No behavior change.

Refs #166

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: d5946d63-5054-4db7-8484-2db48414dc6e
@larsxschneider
larsxschneider requested a review from a team as a code owner November 27, 2026 11:06
Copilot AI adaptive review requested due to automatic review settings November 27, 2026 11:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The migration affects the Go baseline and repository-wide golangci-lint v2 configuration, but its CI, formatter, and exclusion behavior requires external execution that is unavailable in this review snapshot.

No open issues 🎉

What changed in this PR

This PR raises the minimum Go version to 1.26 and updates the linting toolchain to golangci-lint v2.15.0 with Go 1.27.4, applying the corresponding code, formatting, dependency, and configuration changes.

Changes:

  • Updates the module and CI toolchains for supported Go and golangci-lint releases.
  • Migrates the golangci-lint configuration to v2 syntax.
  • Applies Go modernization and formatting updates, including slices.Concat usage.
File Description
sizes/​path_resolver.go Removes unused method receiver names.
sizes/​output.go Updates documentation formatting and removes an obsolete lint suppression.
sizes/​graph.go Simplifies file-mode dispatch logic.
internal/​testutils/​repoutils.go Uses slices.Concat to construct Git command arguments.
internal/​refopts/​filter_value.go Updates documentation list formatting.
go.sum Removes obsolete module checksum entries.
go.mod Raises the required Go version to 1.26.
git/​reference.go Updates documentation formatting.
git/​ref_filter.go Removes unused method receiver names.
git/​gitconfig.go Updates documentation example formatting.
git/​git.go Uses slices.Concat to construct Git command arguments.
git-sizer.go Simplifies declarations and boolean validation expressions.
.golangci.toml Migrates the lint configuration to the golangci-lint v2 schema.
.github/​workflows/​lint.yml Updates the lint workflow to Go 1.27.4 and golangci-lint 2.15.0.

Review effort: Lite (adaptive)

go.mod still declared `go 1.17`, a release that has been
unsupported for years. Raise it to `go 1.26`, the oldest supported
release. Don't go higher: gitrpcd builds the vendored git-sizer with
Go 1.26.

golangci-lint 1.43.0 can't lint code that requires a newer Go
release, so move lint.yml to golangci-lint 2.15.0 and Go 1.27.4 and
port .golangci.toml to the v2 format. v2 dropped errcheck's default
`ignore = "fmt:.*"`, so exclude the `fmt.Fprint*` functions
explicitly. Exclude the new noctx check for exec.Command.

Fix the new findings: newer gosec flags `os.Create` with a variable
path (G304), and prealloc flags `append` to a literal. Use
`slices.Concat` for the latter, which needs Go 1.22 and therefore
can't land before the go.mod change.

Refs #166

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: d5946d63-5054-4db7-8484-2db48414dc6e
@larsxschneider
larsxschneider merged commit bca29eb into master Nov 27, 2026
13 checks passed
@larsxschneider
larsxschneider deleted the ls/golangci-lint-v2 branch November 27, 2026 12:16
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.

3 participants