package main import ( "io" "log" "net/http" ) type handler struct{} func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "text/plain") io.WriteString(w, "Hello world!") } func main() { mux := http.NewServeMux() mux.Handle("/{$}", &handler{}) srv := http.Server{ Addr: ":8080", Handler: mux, } log.Println("Serving on port 8080...") log.Fatal(srv.ListenAndServe()) }