-
Notifications
You must be signed in to change notification settings - Fork 18k
context: should panic at WithValue but not #54708
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
Comments
Change https://go.dev/cl/426093 mentions this issue: |
I'm not sure we should, this change will break user program that set context value with comparable key type, but non-comparable key value (like your example), but never call Also, the
Not specify PS: next time, you should wait for discussing in the issue before sending a CL. |
i think checking value is comparable is better |
Change https://go.dev/cl/554457 mentions this issue: |
i just want to understand the reason for it why the inside the
if we can make type value as
|
The |
I agree with @cuonglm : I don't think we should change this now. It's a very unusual case, and it's an easy problem to detect and to fix. I don't see a reason to risk breaking existing working code. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
What did you expect to see?
panic at line 13 when call WithValue
What did you see instead?
panic at line 14 when call ctx.Value(key)
The text was updated successfully, but these errors were encountered: