aboutsummaryrefslogtreecommitdiff
path: root/cmd/mobius-hotline-server
diff options
context:
space:
mode:
authorJeff Halter <868228+jhalter@users.noreply.github.com>2025-06-26 14:01:22 -0700
committerJeff Halter <868228+jhalter@users.noreply.github.com>2025-06-26 14:01:22 -0700
commit55b8e77c409761639e95168c77dc22c13e858b6b (patch)
treebf2be552503c2674654f77adf9f5941c62d20668 /cmd/mobius-hotline-server
parent5ec29c573bde2417b5d8788966af2577332ce0fc (diff)
Replace filepath.Join with path.Join for Windows compatibility
Replace all instances of filepath.Join with path.Join across the codebase to improve Windows compatibility following the guidance from https://github.com/golang/go/issues/44305. Key changes: - Replaced filepath.Join with path.Join in 14 files - Updated import statements appropriately - Resolved variable shadowing issues where function parameters named 'path' were conflicting with the path package - Maintained filepath imports where needed for OS-specific functions like filepath.Walk, filepath.IsAbs, filepath.Dir, and filepath.Base All tests pass, confirming the changes maintain functionality while improving cross-platform compatibility.
Diffstat (limited to 'cmd/mobius-hotline-server')
-rw-r--r--cmd/mobius-hotline-server/main.go7
-rw-r--r--cmd/mobius-hotline-server/main_test.go16
2 files changed, 11 insertions, 12 deletions
diff --git a/cmd/mobius-hotline-server/main.go b/cmd/mobius-hotline-server/main.go
index e230771..afad4d1 100644
--- a/cmd/mobius-hotline-server/main.go
+++ b/cmd/mobius-hotline-server/main.go
@@ -10,7 +10,6 @@ import (
"os"
"os/signal"
"path"
- "path/filepath"
"syscall"
"github.com/jhalter/mobius/hotline"
@@ -108,7 +107,7 @@ func main() {
os.Exit(1)
}
- srv.AccountManager, err = mobius.NewYAMLAccountManager(filepath.Join(*configDir, "Users/"))
+ srv.AccountManager, err = mobius.NewYAMLAccountManager(path.Join(*configDir, "Users/"))
if err != nil {
slogger.Error(fmt.Sprintf("Error loading accounts: %v", err))
os.Exit(1)
@@ -120,7 +119,7 @@ func main() {
os.Exit(1)
}
- bannerPath := filepath.Join(*configDir, config.BannerFile)
+ bannerPath := path.Join(*configDir, config.BannerFile)
srv.Banner, err = os.ReadFile(bannerPath)
if err != nil {
slogger.Error(fmt.Sprintf("Error loading accounts: %v", err))
@@ -146,7 +145,7 @@ func main() {
}
// Let's try to reload the banner
- bannerPath := filepath.Join(*configDir, config.BannerFile)
+ bannerPath := path.Join(*configDir, config.BannerFile)
srv.Banner, err = os.ReadFile(bannerPath)
if err != nil {
slogger.Error(fmt.Sprintf("Error reloading banner: %v", err))
diff --git a/cmd/mobius-hotline-server/main_test.go b/cmd/mobius-hotline-server/main_test.go
index 17a2cb4..ed63065 100644
--- a/cmd/mobius-hotline-server/main_test.go
+++ b/cmd/mobius-hotline-server/main_test.go
@@ -2,7 +2,7 @@ package main
import (
"os"
- "path/filepath"
+ "path"
"testing"
"github.com/jhalter/mobius/internal/mobius"
@@ -30,7 +30,7 @@ func TestCopyDir(t *testing.T) {
}
for _, expectedFile := range expectedFiles {
- fullPath := filepath.Join(dstDir, expectedFile)
+ fullPath := path.Join(dstDir, expectedFile)
assert.FileExists(t, fullPath, "Expected file %s to exist", expectedFile)
// Verify file is not empty
@@ -46,7 +46,7 @@ func TestCopyDir(t *testing.T) {
}
for _, expectedDir := range expectedDirs {
- fullPath := filepath.Join(dstDir, expectedDir)
+ fullPath := path.Join(dstDir, expectedDir)
info, err := os.Stat(fullPath)
require.NoError(t, err)
assert.True(t, info.IsDir(), "Expected %s to be a directory", expectedDir)
@@ -69,11 +69,11 @@ func TestCopyDirRecursive(t *testing.T) {
require.NoError(t, err)
// Verify nested structure is copied correctly
- nestedPath := filepath.Join(dstDir, "Users", "admin.yaml")
+ nestedPath := path.Join(dstDir, "Users", "admin.yaml")
assert.FileExists(t, nestedPath)
// Verify nested Files directory
- filesDir := filepath.Join(dstDir, "Files")
+ filesDir := path.Join(dstDir, "Files")
info, err := os.Stat(filesDir)
require.NoError(t, err)
assert.True(t, info.IsDir())
@@ -81,7 +81,7 @@ func TestCopyDirRecursive(t *testing.T) {
func TestCopyFile(t *testing.T) {
dstDir := t.TempDir()
- dstFile := filepath.Join(dstDir, "copied.yaml")
+ dstFile := path.Join(dstDir, "copied.yaml")
// Copy a single file from embedded config
err := copyFile("mobius/config/config.yaml", dstFile)
@@ -99,7 +99,7 @@ func TestCopyFile(t *testing.T) {
func TestCopyFileErrors(t *testing.T) {
t.Run("source file does not exist", func(t *testing.T) {
dstDir := t.TempDir()
- err := copyFile("nonexistent.txt", filepath.Join(dstDir, "dest.txt"))
+ err := copyFile("nonexistent.txt", path.Join(dstDir, "dest.txt"))
assert.Error(t, err)
assert.Contains(t, err.Error(), "failed to open source file")
})
@@ -118,7 +118,7 @@ func TestCopyDirPermissions(t *testing.T) {
require.NoError(t, err)
// Check directory permissions
- info, err := os.Stat(filepath.Join(dstDir, "Users"))
+ info, err := os.Stat(path.Join(dstDir, "Users"))
require.NoError(t, err)
assert.True(t, info.IsDir())