Skip to content

fix(golangci-lint): check Go support from the Go that built golangci-lint - #1269

Draft
malept wants to merge 3 commits into
mainfrom
malept-claude/dt-5669/fix/golangci-lint-go-support-from-build-info
Draft

malept wants to merge 3 commits into
mainfrom
malept-claude/dt-5669/fix/golangci-lint-go-support-from-build-info

Conversation

@malept

@malept malept commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

What this PR does / why we need it

Replace the hardcoded "Go 1.26 and later requires golangci-lint 2.9.0 or later" check in shell/golangci-lint.sh with a check against the Go version that built the installed golangci-lint, read from golangci-lint --version. The wrapper now stops when the Go toolchain is newer than the Go that built golangci-lint. The old check needed a manual edit for each new Go minor version.

This is stricter for future Go versions: a Go 1.27 toolchain stops the wrapper until golangci-lint is upgraded to a release built with Go 1.27.

Jira ID

DT-5669

Notes for your reviewers

The result for the old rule is unchanged: Go 1.26 with golangci-lint 2.8.0 still fails and Go 1.26 with 2.9.0 still passes, because 2.9.0 is the first release built with Go 1.26.

If the build Go of golangci-lint or the version of the toolchain can't be read, such as with a development build of Go, the wrapper prints a warning to stderr and continues.

The new block of golangci-lint.sh was run with stubbed --version output for these cases: same Go, older build, development toolchain, release candidate of a newer minor version, and an unreadable build string. The parser was also run on the real output of a local golangci-lint --version.

golangci_lint_supports_go returns 1 when the toolchain is newer and 2 when the toolchain version has no major and minor version. It uses parse_version and has_minimum_version, so the calling script has to source version.sh. This is documented in the header of go.sh.

Considered and dismissed review findings
  • The check compares the installed Go toolchain with the Go that built golangci-lint, and not with the go directive of the module. golangci-lint already checks the module version itself. This check keeps what the old hardcoded check did, which also used the toolchain.
  • go.sh uses functions from version.sh without sourcing it. The other files in shell/lib do not source their dependencies either, so the dependency is documented in the header and the calling script sources both files.
  • The golangci-lint version is read with awk '{print $4}' and the Go version with a pattern, from the same line. The version parsing is unchanged from before, so it stays as is.
  • Extra output from mise on stdout could shift the parsed fields. This is speculative, and the version field already had the same exposure.

Generated by Claude Code

…lint

The check that Go 1.26 needs golangci-lint 2.9.0 compared two numbers
that were written in the script, so each new Go minor version needed a
new edit. golangci-lint reports the Go that built it, so compare the
toolchain with that instead. The same release is accepted, and nothing
has to change for the next Go version. A build that does not report a Go
version only logs a warning.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0127vQEN9nqyQU9EHG8T81wf
The Go support check parsed the toolchain version with parse_version, so a
development toolchain passed the check without a comparison, and a
prerelease printed printf errors. Read the major and minor version of the
toolchain with a pattern instead, and warn and continue when there is none.
Also send the warning for an unreadable golangci-lint build to stderr, so
that it does not mix into the output of golangci-lint.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0127vQEN9nqyQU9EHG8T81wf
…ne only

Anchor the Go version of golangci-lint on the golangci-lint version line and
print the first match only, so that other output, or a second line, cannot
change the result. Document in go.sh that golangci_lint_supports_go needs
version.sh, which the calling script sources. Reword the comment in
golangci-lint.sh to say that devbase requires this, and not golangci-lint.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0127vQEN9nqyQU9EHG8T81wf
@malept
malept marked this pull request as ready for review October 31, 2026 01:43
@malept
malept requested a review from a team as a code owner October 31, 2026 01:43
@malept
malept marked this pull request as draft October 31, 2026 01:44
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.

2 participants