go/packages: use strings.EqualFold in sameFile to handle case-insensitive file systems

Name of file or URI must be checked ignorecase on Windows.

Change-Id: I61507b0aa95389c5e1f421f0702ba6ad17b79177
Reviewed-on: https://go-review.googlesource.com/c/160597
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This commit is contained in:
Yasuhiro Matsumoto 2019-01-31 20:02:48 +09:00 committed by Rebecca Stambler
parent 40960b6deb
commit 4892ae6946
1 changed files with 2 additions and 1 deletions

View File

@ -19,6 +19,7 @@ import (
"log"
"os"
"path/filepath"
"strings"
"sync"
"golang.org/x/tools/go/gcexportdata"
@ -838,7 +839,7 @@ func sameFile(x, y string) bool {
// overlay case implies x==y.)
return true
}
if filepath.Base(x) == filepath.Base(y) { // (optimisation)
if strings.EqualFold(filepath.Base(x), filepath.Base(y)) { // (optimisation)
if xi, err := os.Stat(x); err == nil {
if yi, err := os.Stat(y); err == nil {
return os.SameFile(xi, yi)