Files
lenz-web/templates/embed_dev.go
Simon Martens df79656c77 Better inital
2026-02-18 16:28:05 +01:00

30 lines
486 B
Go

//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)
}