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 bare string used as context key. #17

Closed
anzdaddy opened this issue Aug 26, 2019 · 1 comment · Fixed by #59
Closed

Remove bare string used as context key. #17

anzdaddy opened this issue Aug 26, 2019 · 1 comment · Fixed by #59

Comments

@anzdaddy
Copy link

anzdaddy commented Aug 26, 2019

The following code uses a bare string as a context key. This is a bug.

req = req.WithContext(context.WithValue(req.Context(), "id", i))

ctx = context.WithValue(ctx, "id", <-ph.ids)

@camh-
Copy link
Collaborator

camh- commented Aug 26, 2019

Also, as per @anzdaddy's comment on #16: "https://golang.org/pkg/sync/atomic/#AddUint64 would be simpler, probably faster and won't leak a goroutine."

While there, may as well fix that too.

samuong added a commit that referenced this issue Oct 15, 2020
Also, use sync/atomic's AddUint64() to generate IDs, which is simpler
and avoids tying up a goroutine.

Fixes #17
samuong added a commit that referenced this issue Oct 15, 2020
Also, use sync/atomic's AddUint64() to generate IDs, which is simpler
and avoids tying up a goroutine.

Fixes #17
samuong added a commit that referenced this issue Oct 16, 2020
Also, use sync/atomic's AddUint64() to generate IDs, which is simpler
and avoids tying up a goroutine.

Fixes #17
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 a pull request may close this issue.

2 participants