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
net/http: Server panics with non-comparable Listener (because of map[net.Listener]struct{}) #24812
Comments
This is true, but there's no real fix, and it doesn't seem worth documenting. Last time this came up, it seemed hypothetical at best and an audit of custom net.Listener types in the wild found they were all comparable anyway. If we document too much, the docs become bloated and less valuable. If we did document it somewhere, I'd do it on the net.Listener type and not in net/http at all. The net.Listener type might say "Implementations of Listener are often expected to be comparable." or something. But I'd rather not document that either. I'm going to close this, but let me know if this actual arose in practice. That might warrant docs. But if it's just hypothetical, I'd prefer to do nothing. |
Maybe you are right that it is not worth doing, but there is a fix.
No, it didn't, I was just reading the code. I understand the concern about bloating the documentation, therefore if you understood my points and prefer to do nothing I'm satisfied with it. |
Oh! I thought we did more with it than we do. Storing a pointer to interface sounds fine. Want to send the change? |
Thanks for your reply, I'm not ready to contribute at the moment. |
Change https://golang.org/cl/106657 mentions this issue: |
https://play.golang.org/p/_O9zzZhdd-z
Usually net.Listeners are pointers, therefore comparable, but I would expect non-pointer net.Listeners to work just fine.
If my expectation is correct, perhaps this behavior should be documented.
Or the type of
Server.listeners
could be changed tomap[*net.Listener]struct{}
.The text was updated successfully, but these errors were encountered: