From bd3b2817f2795f3ce8dbc03a6a570d077233175c Mon Sep 17 00:00:00 2001 From: Patryk Hegenberg Date: Fri, 24 Nov 2023 21:49:46 +0100 Subject: [PATCH] use go:embed to include forms.html into cpmpiled binary --- main.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 6e60a40..4d8aa7f 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,7 @@ package main import ( + "embed" "encoding/json" "fmt" "html/template" @@ -97,6 +98,8 @@ type Source struct { var ( mu sync.Mutex chars []Character + //go:embed forms.html + page embed.FS ) func main() { @@ -112,7 +115,7 @@ func main() { // formHandler zeigt das Formular an func formHandler(filename string) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - tmpl, err := template.ParseFiles("forms.html") + tmpl, err := template.ParseFS(page, "forms.html") if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return