From 7d7bf6ae05dffec29396e450d12c588f27f451a6 Mon Sep 17 00:00:00 2001 From: Daniel Legt Date: Thu, 26 Feb 2026 22:18:08 +0200 Subject: [PATCH] Setup for being a library --- main.go => examples/web/main.go | 8 ++++++-- {templates => examples/web/templates}/index.html | 0 go.mod | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) rename main.go => examples/web/main.go (96%) rename {templates => examples/web/templates}/index.html (100%) diff --git a/main.go b/examples/web/main.go similarity index 96% rename from main.go rename to examples/web/main.go index 601bfe5..b47122d 100644 --- a/main.go +++ b/examples/web/main.go @@ -1,6 +1,7 @@ package main import ( + "embed" "fmt" "html/template" "image/color" @@ -12,7 +13,7 @@ import ( "strings" "time" - "test-maze/maze" + maze "tea.chunkbyte.com/kato/go-maze/maze" ) const ( @@ -41,7 +42,10 @@ type mazeParams struct { SolveB uint8 } -var pageTmpl = template.Must(template.ParseFiles("templates/index.html")) +//go:embed templates/index.html +var templatesFS embed.FS + +var pageTmpl = template.Must(template.ParseFS(templatesFS, "templates/index.html")) type pageData struct { mazeParams diff --git a/templates/index.html b/examples/web/templates/index.html similarity index 100% rename from templates/index.html rename to examples/web/templates/index.html diff --git a/go.mod b/go.mod index ca6bf98..f7abefe 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ -module test-maze +module tea.chunkbyte.com/kato/go-maze go 1.25.5