Description
On Windows, the CLI displays mixed-separator filesystem paths when computing the
default config location. The home portion uses backslashes (correctly, from
os.UserHomeDir()), but everything appended afterwards uses forward slashes.
This happens because pkg/config/localconfig.go uses the path package for
filesystem paths. From the Go documentation:
Package path implements utility routines for manipulating slash-separated
paths, such as paths in URLs. The path/filepath package should be used
for paths that interact with the operating system's filesystem.
— https://pkg.go.dev/path
path.Join always uses / regardless of OS. The correct API for filesystem
paths is filepath.Join, which uses the OS-specific separator.
Affected code
pkg/config/localconfig.go uses path.Join / path.Dir in six places:
- Line 112 —
DefaultConfigDir: path.Join(homeDir, ".config", "microcks")
- Line 133 —
DefaultLocalConfigPath: path.Join(dir, "config")
- Line 142 —
DefaultLocalWatchPath: path.Join(dir, "watch")
- Line 158 —
WriteLocalConfig: path.Dir(configPath)
- Line 410 —
WriteLocalWatchConfig: path.Dir(cfgPath)
- Line 6 —
import "path"
Reproduction (Windows 11, PowerShell or cmd)
> .\microcks.exe --help
...
--config string Path to Microcks config (default "C:\Users\<USER>/.config/microcks/config")
^ ^ forward slash after the user dir
> .\microcks.exe context
2026/05/27 00:35:59 No contexts defined in C:\Users\<USER>/.config/microcks/config
Expected
C:\Users\<USER>\.config\microcks\config
Proposed fix
Replace the path package with path/filepath for all filesystem path
construction in pkg/config/localconfig.go. The semantics are identical on
Unix (both produce /-separated paths) and correct on Windows.
I'm happy to send a PR if maintainers agree.
Environment
- OS: Windows 11
- Go: go1.26.2 windows/amd64
- Branch:
main (development version 1.0.3)
Description
On Windows, the CLI displays mixed-separator filesystem paths when computing the
default config location. The home portion uses backslashes (correctly, from
os.UserHomeDir()), but everything appended afterwards uses forward slashes.This happens because
pkg/config/localconfig.gouses thepathpackage forfilesystem paths. From the Go documentation:
path.Joinalways uses/regardless of OS. The correct API for filesystempaths is
filepath.Join, which uses the OS-specific separator.Affected code
pkg/config/localconfig.gousespath.Join/path.Dirin six places:DefaultConfigDir:path.Join(homeDir, ".config", "microcks")DefaultLocalConfigPath:path.Join(dir, "config")DefaultLocalWatchPath:path.Join(dir, "watch")WriteLocalConfig:path.Dir(configPath)WriteLocalWatchConfig:path.Dir(cfgPath)import "path"Reproduction (Windows 11, PowerShell or cmd)
Expected
Proposed fix
Replace the
pathpackage withpath/filepathfor all filesystem pathconstruction in
pkg/config/localconfig.go. The semantics are identical onUnix (both produce
/-separated paths) and correct on Windows.I'm happy to send a PR if maintainers agree.
Environment
main(development version1.0.3)