use-errors-new: disable for Go 1.26#1697
Merged
alexandear merged 3 commits intomgechev:masterfrom Mar 25, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the use-errors-new lint rule to be effectively disabled for Go 1.26+ codebases, aligning the rule’s guidance with the Go 1.26 fmt.Errorf optimization for non-formatting usage.
Changes:
- Skip
use-errors-newanalysis when the package Go version is at least 1.26. - Add Go 1.26 test fixtures (nested
testdata/go1.26module) to validate the rule is disabled. - Introduce a
lint.Go126version constant and extend the unit test to cover the new fixture.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
rule/use_errors_new.go |
Adds Go 1.26+ early return to disable rule execution. |
lint/package.go |
Adds Go126 version constant used by rules for version gating. |
test/use_errors_new_test.go |
Runs the rule against the Go 1.26-scoped fixture. |
testdata/go1.26/go.mod |
Declares a Go 1.26 nested module for version detection in tests. |
testdata/go1.26/use_errors_new.go |
Fixture ensuring fmt.Errorf("literal") is not flagged under Go 1.26. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Contributor
|
What about something in the rules description file |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For unformatted strings,
fmt.Errorf("x")in Go 1.26 allocates less and generally matches the allocations forerrors.New("x"). See https://go.dev/doc/go1.26#fmtpkgfmt