fix(config): use path/filepath for OS-correct path separators#442
Open
hazelmayank wants to merge 1 commit into
Open
fix(config): use path/filepath for OS-correct path separators#442hazelmayank wants to merge 1 commit into
hazelmayank wants to merge 1 commit into
Conversation
Signed-off-by: hazelmayank <mayankjeefinal@gmail.com>
8eb1fc2 to
c2239df
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace the
pathpackage withpath/filepathinpkg/config/localconfig.goso 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.gowas usingpath.Join/path.Dirto construct filesystempaths. On Windows this produced mixed-separator paths because
os.UserHomeDir()returns backslashes but
path.Jointhen appended with forward slashes.Changes
pkg/config/localconfig.go:import "path"withimport "path/filepath".path.Joincalls withfilepath.Join(lines 112, 133, 142).path.Dircalls withfilepath.Dir(lines 158, 410).No other files needed changes —
pathwas only used in this file for filesystempath construction.
Before / After (Windows 11)
Before:

After:

Linux / macOS output is unchanged.
Test plan
go build .succeeds on Windows.microcks --helpshows all-backslash default config path on Windows.microcks contextshows all-backslash path on Windows.Related
This is in the same family as #352 / PR #353 (Windows absolute path parsing).