main.go
package main import ( "html/template" "log" "net/http" ) func main() { http.HandleFunc("/", rootHandler) log.Fatal(http.ListenAndServe(":8080", nil)) } func rootHandler(w http.ResponseWriter, r *http.Request) { render(w, "templates/form.html", nil) } func render(w http.ResponseWriter, filename string, data interface{}) { tmpl, err := template.ParseFiles(filename) if err != nil { log.Println(err) http.Error(w, "Sorry, something went wrong", http.StatusInternalServerError) } if err := tmpl.Execute(w, data); err != nil { log.Println(err) http.Error(w, "Sorry, something went wrong", http.StatusInternalServerError) } }