Use http.Handler as an interface for types that implement ServeHTTP, and http.HandlerFunc as a function type that satisfies that interface. Convert a function to a handler by assigning it to http.HandlerFunc and pass it to http.ListenAndServe.
package main
import (
"fmt"
"net/http"
)
func main() {
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, %s", r.URL.Path)
})
http.ListenAndServe(":8080", handler)
}