package main import ( "html/template" "log" "net/http" _ "embed" "github.com/pkg/errors" ) var ( //go:embed index.gohtml indexTmpl string ) func main() { tmpl, err := template.New("").Parse(indexTmpl) if err != nil { log.Fatalf("[FATAL] %+v", errors.WithStack(err)) } handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { data := struct { Request *http.Request }{ Request: r, } if err := tmpl.Execute(w, data); err != nil { log.Printf("[ERROR] %+v", errors.WithStack(err)) } }) addr := ":3000" log.Printf("[INFO] listening on '%s'", addr) if err := http.ListenAndServe(addr, handler); err != nil { log.Fatalf("[FATAL] %+v", errors.WithStack(err)) } }