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

Closed
opened 2026-03-12 23:53:35 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/0xJacky/nginx-ui/pull/1391
Author: @Alireza-Gholiei
Created: 10/13/2025
Status: Merged
Merged: 10/16/2025
Merged by: @0xJacky

Base: devHead: fix/template-path-embed


📝 Commits (1)

  • f621e16 fix(template): use path.Join and rename param to avoid Windows embed path issue

📊 Changes

1 file changed (+5 additions, -3 deletions)

View changed files

📝 internal/template/template.go (+5 -3)

📄 Description

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.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/0xJacky/nginx-ui/pull/1391 **Author:** [@Alireza-Gholiei](https://github.com/Alireza-Gholiei) **Created:** 10/13/2025 **Status:** ✅ Merged **Merged:** 10/16/2025 **Merged by:** [@0xJacky](https://github.com/0xJacky) **Base:** `dev` ← **Head:** `fix/template-path-embed` --- ### 📝 Commits (1) - [`f621e16`](https://github.com/0xJacky/nginx-ui/commit/f621e16d7d31c9fc3d007b30d0a3e51a4ba5f8be) fix(template): use path.Join and rename param to avoid Windows embed path issue ### 📊 Changes **1 file changed** (+5 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `internal/template/template.go` (+5 -3) </details> ### 📄 Description ### 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-12 23:53:35 +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#8401
No description provided.