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
context: Clarify desired key type #30408
Comments
Duplicate of #17826? If you think the documentation is lacking, please point out what is missing. |
The current documentation says:
So using a string value is clearly out, even if you assign it to a variable of type |
Aliasing anything to |
Duplicate of #17826 |
In that case, have the compiler reject string keys for context API calls |
Hi, I am trying to resolve some interesting linter warnings around context key types. For some reason, ordinary strings are being discouraged as context key types, e.g. by
golint
.One specific recommendation online is to use
interface{}
instead. Is this a good idea?Could we use the Go type system to make this easier for the user? Perhaps alias
interface{}
as aContextKey
type, and require in theContext
API methods that the keys are passed in with theContextKey
type.The text was updated successfully, but these errors were encountered: