Skip to content

fix(config): use path/filepath for OS-correct path separators#442

Open
hazelmayank wants to merge 1 commit into
microcks:masterfrom
hazelmayank:fix/config-filepath-join
Open

fix(config): use path/filepath for OS-correct path separators#442
hazelmayank wants to merge 1 commit into
microcks:masterfrom
hazelmayank:fix/config-filepath-join

Conversation

@hazelmayank
Copy link
Copy Markdown
Contributor

@hazelmayank hazelmayank commented May 26, 2026

Summary

Replace the path package with path/filepath in pkg/config/localconfig.go
so the CLI builds filesystem paths with the OS-correct separator.

Fixes #441 .

Background

The Go standard library splits path manipulation across two packages:

  • path — always uses /. Meant for URLs and slash-separated paths.
  • path/filepath — uses the OS-specific separator. Meant for filesystem paths.

localconfig.go was using path.Join / path.Dir to construct filesystem
paths. On Windows this produced mixed-separator paths because os.UserHomeDir()
returns backslashes but path.Join then appended with forward slashes.

Changes

pkg/config/localconfig.go:

  • Replaced import "path" with import "path/filepath".
  • Replaced 3 path.Join calls with filepath.Join (lines 112, 133, 142).
  • Replaced 2 path.Dir calls with filepath.Dir (lines 158, 410).

No other files needed changes — path was only used in this file for filesystem
path construction.

Before / After (Windows 11)

Before:
WhatsApp Image 2026-05-27 at 00 38 06



> microcks --help
      --config string   Path to Microcks config (default "C:\Users\<USER>/.config/microcks/config")
> microcks context
2026/05/27 00:35:59 No contexts defined in C:\Users\<USER>/.config/microcks/config

After:
image



> microcks --help
      --config string   Path to Microcks config (default "C:\Users\<USER>\.config\microcks\config")
> microcks context
2026/05/27 00:35:59 No contexts defined in C:\Users\<USER>\.config\microcks\config

Linux / macOS output is unchanged.

Test plan

  • go build . succeeds on Windows.
  • microcks --help shows all-backslash default config path on Windows.
  • microcks context shows all-backslash path on Windows.
  • CI passes on all platforms.

Related

This is in the same family as #352 / PR #353 (Windows absolute path parsing).

Signed-off-by: hazelmayank <mayankjeefinal@gmail.com>
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.

Default config path uses forward slashes on Windows, producing mixed-separator paths

1 participant