Skip to content

Commit 030ca34

Browse files
committed
path/filepath: remove extra Clean call in EvalSymlinks on Windows
EvalSymlinks calls Clean twice, one in walkSymlinks and another in toNorm. The later is not necessary, as toNorm is only called by EvalSymlinks and just after walkSymlinks cleans the path without any path manipulation in between. Change-Id: Ibdb782c7eed59468f0ebb913e98d2a7db0df010d Reviewed-on: https://go-review.googlesource.com/c/go/+/454615 TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Bryan Mills <[email protected]> Reviewed-by: Damien Neil <[email protected]> Run-TryBot: Quim Muntal <[email protected]>
1 parent 7135710 commit 030ca34

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/path/filepath/path_windows_test.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,11 @@ func TestToNorm(t *testing.T) {
347347
}
348348

349349
for _, test := range tests {
350-
got, err := filepath.ToNorm(test.arg, stubBase)
350+
var path string
351+
if test.arg != "" {
352+
path = filepath.Clean(test.arg)
353+
}
354+
got, err := filepath.ToNorm(path, stubBase)
351355
if err != nil {
352356
t.Errorf("toNorm(%s) failed: %v\n", test.arg, err)
353357
} else if got != test.want {
@@ -439,7 +443,9 @@ func TestToNorm(t *testing.T) {
439443
continue
440444
}
441445
}
442-
446+
if arg != "" {
447+
arg = filepath.Clean(arg)
448+
}
443449
got, err := filepath.ToNorm(arg, filepath.NormBase)
444450
if err != nil {
445451
t.Errorf("toNorm(%s) failed: %v (wd=%s)\n", arg, err, wd)

src/path/filepath/symlink_windows.go

-2
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ func toNorm(path string, normBase func(string) (string, error)) (string, error)
6363
return path, nil
6464
}
6565

66-
path = Clean(path)
67-
6866
volume := normVolumeName(path)
6967
path = path[len(volume):]
7068

0 commit comments

Comments
 (0)