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

fix: fix referencing the loop variable and avoid slice grow #226

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

qshuai
Copy link

@qshuai qshuai commented Feb 27, 2025

The semantics of for loop variables is controlled by the language version in the module’s go.mod file when using go version 1.22 or later. That is it works well when the version in go module is 1.22 or later. Otherwise the reference using pointer will capture the same loop variable.

In addition, making slice with length avoids slice growing to ensure fairness.

References:

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.

1 participant