title: Showing custom 404 error page with standard http package
body: <p>Assuming that we have:</p>
  
  <pre><code>http.HandleFunc("/smth", smthPage)
  http.HandleFunc("/", homePage)
  </code></pre>
  
  <p>User sees a plain "404 page not found" when they try a wrong URL. How can I return a custom page for that case?</p>
  
  <p><strong>Update concerning gorilla/mux</strong></p>
  
  <p>Accepted answer is ok for those using pure net/http package.</p>
  
  <p>If you use gorilla/mux you should use something like this:</p>
  
  <pre><code>func main() {
      r := mux.NewRouter()
      r.NotFoundHandler = http.HandlerFunc(notFound)
  }
  </code></pre>
  
  <p>And implement <code>func notFound(w http.ResponseWriter, r *http.Request)</code> as you want.</p>