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

doc: Writing web applications ignores error from ListenAndServe #19511

joneskoo opened this issue Mar 11, 2017 · 4 comments

doc: Writing web applications ignores error from ListenAndServe #19511

joneskoo opened this issue Mar 11, 2017 · 4 comments


Copy link

joneskoo commented Mar 11, 2017

Does everyone forget to check the error on ListenAndServe? #golang

Nothing in this tutorial Writing Web Applications, in the Articles section of documentation, seems to indicate that ListenAndServe may return an error. Errors should be checked.
func ListenAndServe(addr string, handler Handler) error
ListenAndServe always returns a non-nil error.

Since I don't see an issue opened by @campoy , I'm opening one.

EDIT: Clarified that the issue is in Article, not the package documentation.

Copy link

qqiao commented Mar 12, 2017

The error isn't ignored in the example. It was first logged, then caused an os.Exit(1)

@bradfitz bradfitz added this to the Go1.9Maybe milestone Mar 21, 2017
@ianlancetaylor ianlancetaylor modified the milestones: Go1.10, Go1.9Maybe Aug 3, 2017
Copy link

Ping @campoy

Copy link

campoy commented Aug 3, 2017

The documentation pointed by @joneskoo is indeed failing silently if http.ListenAndServe returns an error.
Since we're not using the Shutdown method, I'd say that it's safe to simply add log.Fatal.
I'll send a CL

Copy link

Change mentions this issue: docs: add error handling on http.ListenAndServe

@golang golang locked and limited conversation to collaborators Aug 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet

No branches or pull requests

6 participants