Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exportloopref: deprecation #4916

Merged
merged 3 commits into from
Aug 17, 2024
Merged

exportloopref: deprecation #4916

merged 3 commits into from
Aug 17, 2024

Conversation

ldez
Copy link
Member

@ldez ldez commented Aug 15, 2024

Since Go1.22 (and go1.21 with GOEXPERIMENT=loopvar), exportloopref is no longer relevant.

It should be replaced by copyloopvar.

It's a level 1 deprecation (the linter still runs) but we will keep the level 1 until the release of go1.24.

And as golangci-lint requires min go1.22 to compile we can drop variable copies inside the code.

Reminder: the Go team only maintains the 2 latest "minor" versions of Go (go1.22 and go1.23), and go1.22 was released on 2024-02-06, so it's highly recommended not to use go1.21 or lower.

@ldez ldez added the linter: update Update the linter implementation inside golangci-lint label Aug 15, 2024
@ldez ldez added this to the next milestone Aug 15, 2024
@ldez ldez requested a review from bombsimon August 15, 2024 22:24
@leonklingele
Copy link
Member

leonklingele commented Aug 16, 2024 via email

@ldez
Copy link
Member Author

ldez commented Aug 16, 2024

Because the priority is for users to stop using it, they should remove it from their configuration, so the "false-positives" reports will be a reminder.
If we disable the linter, the users will be less insisted on removing it from their configuration.

@leonklingele
Copy link
Member

What about people using --enable-all? Will they really need to explicitly pass --disable exportloopref to prevent the false positives from appearing? Looks quite inconvenient to me — we already know no one on Go 1.22+ wants to see these.

@ldez
Copy link
Member Author

ldez commented Aug 16, 2024

This is how the depreciation cycle works.

Copy link
Member

@bombsimon bombsimon left a comment

Choose a reason for hiding this comment

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

LGTM. I agree not "hiding" this and asking users to disable deprecated linters is the right way so they're aware they will go away. This one might be special since it's bot needed but better to be consistent.

I don't know how common enabling all without a config file is but if you have a config file it's a one time-one line fix.

@ldez ldez merged commit 87dd8fe into golangci:master Aug 17, 2024
16 checks passed
@ldez ldez deleted the fix/exportloopref branch August 17, 2024 11:41
@ldez ldez added the enhancement New feature or improvement label Aug 17, 2024
@ldez ldez modified the milestones: next, v1.60 Aug 20, 2024
uudashr pushed a commit to uudashr/golangci-lint that referenced this pull request Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement linter: update Update the linter implementation inside golangci-lint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants