[release-branch.go1.15] cmd/go: use path.Dir instead of filepath.Dir for package paths in 'go mod vendor'

copyMetadata walk-up to parent directory until the pkg become modPath.
But pkg should be slash-separated paths. It have to use path.Dir instead of
filepath.Dir.

Updates #46867
Fixes #47014

Change-Id: I44cf1429fe52379a7415b94cc30ae3275cc430e8
Reviewed-on: https://go-review.googlesource.com/c/go/+/330149
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Alexander Rakoczy <alex@golang.org>
Trust: Carlos Amedee <carlos@golang.org>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
(cherry picked from commit 835d86a17e)
Reviewed-on: https://go-review.googlesource.com/c/go/+/332330
Reviewed-by: Jay Conrod <jayconrod@google.com>
Run-TryBot: Carlos Amedee <carlos@golang.org>
This commit is contained in:
Yasuhiro Matsumoto 2021-06-23 01:02:33 +09:00 committed by Carlos Amedee
parent 818c5f6fbe
commit 1b68e07a24
1 changed files with 2 additions and 1 deletions

View File

@ -10,6 +10,7 @@ import (
"io"
"io/ioutil"
"os"
"path"
"path/filepath"
"sort"
"strings"
@ -192,7 +193,7 @@ func copyMetadata(modPath, pkg, dst, src string) {
if modPath == pkg {
break
}
pkg = filepath.Dir(pkg)
pkg = path.Dir(pkg)
dst = filepath.Dir(dst)
src = filepath.Dir(src)
}