Skip to content

fix: use path instead of filepath in FSLoader.Abs for Windows compatibility#375

Open
Yanhu007 wants to merge 1 commit intoflosch:masterfrom
Yanhu007:fix/fsloader-path-separator
Open

fix: use path instead of filepath in FSLoader.Abs for Windows compatibility#375
Yanhu007 wants to merge 1 commit intoflosch:masterfrom
Yanhu007:fix/fsloader-path-separator

Conversation

@Yanhu007
Copy link
Copy Markdown

Fixes #373

Problem

FSLoader.Abs() uses filepath.Join and filepath.Dir, which produce backslash-separated paths on Windows. Since fs.FS (including embed.FS) always uses forward slashes per the io/fs specification, template resolution fails on Windows with "unable to resolve template".

Fix

Use path.Join and path.Dir (always forward slashes) instead of filepath.Join and filepath.Dir for FSLoader. LocalFilesystemLoader continues to use filepath since it operates on OS paths.

func (l *FSLoader) Abs(base, name string) string {
    return path.Join(path.Dir(base), name)
}

@Yanhu007 Yanhu007 force-pushed the fix/fsloader-path-separator branch from dcec8e7 to 868a89c Compare April 13, 2026 12:10
FSLoader.Abs uses filepath.Join/Dir which produce backslash-separated
paths on Windows. Since fs.FS (including embed.FS) expects forward
slashes, this causes "unable to resolve template" errors on Windows.

Use the path package (which always uses forward slashes) for FSLoader
path operations, keeping filepath for the LocalFilesystemLoader which
operates on the OS filesystem.

Fixes flosch#373
@Yanhu007 Yanhu007 force-pushed the fix/fsloader-path-separator branch from 868a89c to 86860c4 Compare April 14, 2026 07:36
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"unable to resolve template" error due to wrong seperator on filepaths

1 participant