[PR #1391] fix(template): use path.Join and rename parameter to fix embed path on Windows #5702

Closed
opened 2026-03-01 15:42:20 +03:00 by kerem · 0 comments
Owner

Original Pull Request: https://github.com/0xJacky/nginx-ui/pull/1391

State: closed
Merged: Yes


Summary

This PR fixes an issue where templates embedded with //go:embed couldn't be opened on Windows because paths were constructed with filepath.Join which produces backslashes (e.g. block\letsencrypt.conf). embed.FS expects forward slashes.

Changes

  • Rename function parameter path -> dir in:
    • GetTemplateInfo
    • ParseTemplate
  • Use path.Join(dir, name) instead of filepath.Join(...)
  • Replace import "path/filepath" with import "path" where appropriate.

Why

  • embed.FS normalizes file names with forward slashes (/). On Windows filepath.Join produces backslashes which lead to "file does not exist" errors at runtime.
  • The change preserves cross-platform behavior: path.Join works on Linux/macOS and Windows for embedded resources.
**Original Pull Request:** https://github.com/0xJacky/nginx-ui/pull/1391 **State:** closed **Merged:** Yes --- ### Summary This PR fixes an issue where templates embedded with //go:embed couldn't be opened on Windows because paths were constructed with filepath.Join which produces backslashes (e.g. `block\letsencrypt.conf`). embed.FS expects forward slashes. ### Changes - Rename function parameter `path` -> `dir` in: - `GetTemplateInfo` - `ParseTemplate` - Use `path.Join(dir, name)` instead of `filepath.Join(...)` - Replace `import "path/filepath"` with `import "path"` where appropriate. ### Why - `embed.FS` normalizes file names with forward slashes (`/`). On Windows `filepath.Join` produces backslashes which lead to "file does not exist" errors at runtime. - The change preserves cross-platform behavior: `path.Join` works on Linux/macOS and Windows for embedded resources.
kerem 2026-03-01 15:42:20 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/nginx-ui#5702
No description provided.