1
0
mirror of https://github.com/golang/go synced 2024-11-24 12:40:12 -07:00

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 <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
This commit is contained in:
qmuntal 2022-12-01 21:59:00 +01:00 committed by Quim Muntal
parent 7135710e01
commit 030ca34f57
2 changed files with 8 additions and 4 deletions

View File

@ -347,7 +347,11 @@ func TestToNorm(t *testing.T) {
}
for _, test := range tests {
got, err := filepath.ToNorm(test.arg, stubBase)
var path string
if test.arg != "" {
path = filepath.Clean(test.arg)
}
got, err := filepath.ToNorm(path, stubBase)
if err != nil {
t.Errorf("toNorm(%s) failed: %v\n", test.arg, err)
} else if got != test.want {
@ -439,7 +443,9 @@ func TestToNorm(t *testing.T) {
continue
}
}
if arg != "" {
arg = filepath.Clean(arg)
}
got, err := filepath.ToNorm(arg, filepath.NormBase)
if err != nil {
t.Errorf("toNorm(%s) failed: %v (wd=%s)\n", arg, err, wd)

View File

@ -63,8 +63,6 @@ func toNorm(path string, normBase func(string) (string, error)) (string, error)
return path, nil
}
path = Clean(path)
volume := normVolumeName(path)
path = path[len(volume):]