Embed html files in compiled executable

This commit is contained in:
Joren 2024-09-04 00:06:35 +02:00
parent d46d2b15ba
commit b8c7234ed9
Signed by: Joren
GPG Key ID: 280E33DFBC0F1B55

View File

@ -16,6 +16,8 @@ import (
"sync" "sync"
"time" "time"
"embed"
"github.com/BurntSushi/toml" "github.com/BurntSushi/toml"
) )
@ -60,12 +62,14 @@ type ProgressInfo struct {
var templates *template.Template var templates *template.Template
var templateFS embed.FS
func init() { func init() {
if err := os.MkdirAll(uploadDir, 0755); err != nil { if err := os.MkdirAll(uploadDir, 0755); err != nil {
fmt.Printf("Error creating upload directory: %v\n", err) fmt.Printf("Error creating upload directory: %v\n", err)
} }
templates = template.Must(template.ParseGlob("templates/*")) templates = template.Must(template.ParseFS(templateFS, "templates/*"))
} }
func main() { func main() {