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: ListenAndServe example deadlocks in playground #50045
Comments
net/http.ListenAndServe()
example produces a deadlock
It's, uh... not wrong? If you assume that the only connections that will be accepted come from the program itself (which AFAICT is a valid assumption in the faked world of the Playground), then it really is deadlocked. Shoving the server into the background and making an actual call to it seems to work: |
Thanks for looking! So the TL;DR of this was that I was chatting with someone on my phone, and thought Your updated example looks good (perhaps even better, as it's a more complete example); slightly concerned if the added complexity will distract from the |
FWIW, I think that update may actually be racy. (I'm not sure what it happens to do if the If you're going to use |
A more appropriate example is probably something like https://go.dev/play/p/UFd9OAIjx_B. |
that's almost identical to the "Http Server" example in the playground dropdown |
So it is. Perfect! Then maybe we should replace the |
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?
Run the go playground example for
net/http.ListenAndServe()
(https://play.golang.org/p/j01H9doftSz)What did you expect to see?
Hello, world!
What did you see instead?
See above
The text was updated successfully, but these errors were encountered: