From 7fae2dd7fa51c00517125b1c4bd5079d0d75f28d Mon Sep 17 00:00:00 2001 From: Yanhu007 Date: Tue, 14 Apr 2026 20:45:35 +0800 Subject: [PATCH] fix: use path instead of filepath in FSLoader for fs.FS compatibility FSLoader.Abs used filepath.Join and filepath.Dir which produce backslash-separated paths on Windows. Since fs.FS (including embed.FS) requires forward-slash paths per the Go specification, this caused "unable to resolve template" errors on Windows. Use path.Join and path.Dir instead, which always use forward slashes regardless of platform. Fixes #373 --- template_loader.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/template_loader.go b/template_loader.go index 8d88005..8c0ed1a 100644 --- a/template_loader.go +++ b/template_loader.go @@ -7,6 +7,7 @@ import ( "io/fs" "log" "os" + gopath "path" "path/filepath" ) @@ -25,7 +26,7 @@ func NewFSLoader(fs fs.FS) *FSLoader { } func (l *FSLoader) Abs(base, name string) string { - return filepath.Join(filepath.Dir(base), name) + return gopath.Join(gopath.Dir(base), name) } func (l *FSLoader) Get(path string) (io.Reader, error) {