This is a follow[0] up to this stackoverflow question. I suggest that `http.HandleFunc` and `http.Handle` get some kind of warning in the docs in favor of `http.ServeMux`.
Currently, there are two ways to register a listener. The first one is to call `http.HandleFunc` and `http.ServeMux`, which saves you to create a new Mux but uses a global Mux internally. While this may seem convenient, it is a bit confusing for beginners (ambiguity is something every language should try to avoid) and it uses global state, which is strongly discouraged throughout the docs. Furthermore, using DefaultServeMux also runs the risk of exposing profiling endpoints when using net/http/pprof, since those are attached to the DefaultServeMux (thanks elithrar [1][2]).
Because of those three reasons, I think it is appropriate to add a warning in the Godocs about the shortcomings of those two functions. I'd suggest the docs are changed to "Deprecated, use a ServeMux instead" and the official tutorial[3] is also changed to only use a Mux (this would add 2 more lines, which is acceptable, IMO).
I'd like to know what you think about this issue.
- Matt3o12 (Matteo Kloiber)