The function `notfound` is a plain function. It has a specific signature, (w http.ResponseWriter, r *http.Request). There is a type, HandlerFunc, with the following specification:
type HandlerFunc func(ResponseWriter, *Request)
Types in Go are "generative", so the HandlerFunc type is different from a plain function. But if we wrap it, like your code does, we "lift" the plain function into becoming a HandlerFunc. Now, why do we do that? Well, HandlerFunc implements the Handler interface:
// ServeHTTP calls f(w, r).
func (f HandlerFunc) ServeHTTP(w ResponseWriter, r *Request) {
f(w, r)
}
And the http server uses the Handler interface all over the place. This allows us to "adapt" any function with the right signature into an http.Handler. Had we just passed the plain function, the trouble is that it doesn't implement the ServeHTTP method. And we need this for the Handler interface.
In short, we can "tag" a function as being an http.Handler and use it as one in our web server by adapting through the HandlerFunc type.
Other people might have comments here as to my specificity wrt the explanation.
J.