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

cmd/vet: add check for Context.WithValue(_, string, _) #17293

Closed
bradfitz opened this issue Sep 30, 2016 · 6 comments

Comments

Projects
None yet
5 participants
@bradfitz
Copy link
Member

commented Sep 30, 2016

Using a context.Context Value key of type string is a terrible idea and walks into the minefield of a global namespace. We should've outlawed it from day 1.

All context value keys should be made from user-defined types.

Also disallow int, bool, etc. But string is what I usually see.

@bradfitz bradfitz added this to the Go1.8 milestone Sep 30, 2016

@mdlayher

This comment has been minimized.

Copy link
Member

commented Sep 30, 2016

I'd be happy to give this a try.

@bradfitz

This comment has been minimized.

Copy link
Member Author

commented Sep 30, 2016

Thanks.

@bradfitz bradfitz closed this Sep 30, 2016

@bradfitz bradfitz reopened this Sep 30, 2016

@mdlayher

This comment has been minimized.

Copy link
Member

commented Sep 30, 2016

Submitted an initial CL here: https://go-review.googlesource.com/c/30084/.

I suspect there's probably more I can do, but I would appreciate some review before I pursue this issue further.

@robpike

This comment has been minimized.

Copy link
Contributor

commented Sep 30, 2016

This is not a correctness issue and so should not be fixed in vet. It's a better candidate for lint.

@gopherbot

This comment has been minimized.

Copy link

commented Sep 30, 2016

CL https://golang.org/cl/30084 mentions this issue.

@dsnet

This comment has been minimized.

Copy link
Member

commented Oct 1, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.