package web import ( "html/template" "net/http" "git.fjla.uk/fred.boniface/barcodes/validation" ) func helpTemplate(w http.ResponseWriter, r *http.Request) { i := 0 barcodeOptions := make([]string, len(validation.FormatRules)) for k := range validation.FormatRules { barcodeOptions[i] = k i++ } type dataType struct { BarcodeOptions []string } data := dataType{ BarcodeOptions: barcodeOptions, } tmpl := template.Must(template.New("base.html").ParseFiles("templates/base.html", "templates/help.html")) err := tmpl.Execute(w, data) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } }