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

Remove extra loop var copies #852

Merged
merged 1 commit into from
Feb 8, 2024
Merged

Remove extra loop var copies #852

merged 1 commit into from
Feb 8, 2024

Conversation

sevein
Copy link
Contributor

@sevein sevein commented Feb 2, 2024

In preparation for the go1.22 release, this pull request removes the copy of the loop variable that we used to need to prevent sharing in per-iteration closures or goroutines. I haven't found yet a tool that can remove these automatically, for now I find them in vscode using \b(\w+)\s*:=\s*\1\b$. Or:

grep --recursive --include=\*.go --perl-regexp '\b(\w+)\s*:=\s*\1\b$' .

I'll keep this as a draft until go1.22 is released.

Context: https://go.dev/wiki/LoopvarExperiment.

@sevein sevein force-pushed the dev/loopvar-copy-remove branch from 4207c4c to 2ff601c Compare February 8, 2024 12:09
Copy link

codecov bot commented Feb 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (3c851dd) 45.30% compared to head (2ff601c) 45.29%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #852      +/-   ##
==========================================
- Coverage   45.30%   45.29%   -0.02%     
==========================================
  Files          93       93              
  Lines        5039     5036       -3     
==========================================
- Hits         2283     2281       -2     
+ Misses       2553     2552       -1     
  Partials      203      203              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sevein sevein marked this pull request as ready for review February 8, 2024 12:13
@sevein sevein merged commit 0c1b843 into main Feb 8, 2024
12 of 13 checks passed
@sevein sevein deleted the dev/loopvar-copy-remove branch February 8, 2024 16:26
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