Better inital

This commit is contained in:
Simon Martens
2026-02-18 16:28:05 +01:00
parent e9f1d32e3a
commit df79656c77
22 changed files with 1850 additions and 30 deletions

29
templates/embed_dev.go Normal file
View File

@@ -0,0 +1,29 @@
//go:build dev
package templates
import (
"io/fs"
"log"
"os"
"path/filepath"
"runtime"
)
var (
FS fs.FS
PublicFS fs.FS
)
// INFO: We use the currrent embeds file path to create the FS.
// This is used in builds tagged with dev only, to serve files from the FS.
func init() {
_, file, _, ok := runtime.Caller(0)
if !ok {
log.Fatal("cannot resolve templates path from runtime.Caller")
}
base := filepath.Dir(file)
FS = os.DirFS(base)
PublicFS = os.DirFS(base)
}