The error that ends an HTTP server is dropped, so a failure to serve goes unnoticed
What it finds
http.ListenAndServe(":8080", mux) as a statement: the call blocks while the server runs and returns only with an error, such as an address already in use, which nothing reads here, so the program goes on, or ends, without saying why it serves nothing.
Reported are expression statements and go statements that call http.ListenAndServe, http.ListenAndServeTLS, http.Serve or http.ServeTLS, or the methods ListenAndServe, ListenAndServeTLS, Serve and ServeTLS of a variable declared as an http.Server.
From the rule's source, listen_error_ignored.rs.
package p import ( "log" "net/http") func serve(srv *http.Server, other *custom) { other.Serve(1) go http.ListenAndServe(":6060", nil)tx0 reports: the error that stops the server is not checked srv.ListenAndServe()tx0 reports: the error that stops the server is not checked log.Fatal(http.ListenAndServe(":8080", nil))} type custom struct{} func (*custom) Serve(int) {} Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/go:listen-error-ignored" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/go:listen-error-ignored] reason="..."tx0 explain tx0/go:listen-error-ignored shows the same in the terminal. Found a false positive? Report it.