Fix loop variable captured by func literal #2660
Merged
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.
Description
by running
go vet ./...
with go latest version there are some warning about loop variable captured by func literalthis is linked to
https://github.com/golang/go/wiki/CommonMistakes#using-reference-to-loop-iterator-variable
and
https://github.com/golang/go/wiki/LoopvarExperiment
I have no idea how to fix the
possible misuse of unsafe.Pointer
(this can be a false positive, someone with experience in windows and go unsafe must check) but the loop variable is easierHowever this trigger some random 500 errors in the middleware/pprof because some handlers are not supposed to be called more than once at same time.
We can see outputs like
Could not enable tracing: runtime error: tracing is already enabled
or
Could not enable CPU profiling: cpu profiling already in use
I remove the
t.Parallel()
of such testsType of change
minor change in tests
Checklist:
Commit formatting:
Use emojis on commit messages so it provides an easy way of identifying the purpose or intention of a commit. Check out the emoji cheatsheet here: https://gitmoji.carloscuesta.me/