diff --git a/context.go b/context.go index 00a2d363ea..b9741297a1 100644 --- a/context.go +++ b/context.go @@ -179,7 +179,7 @@ func (c *Ctx) DetectProjectGOPATH(p *Project) (string, error) { pGOPATH, perr := c.detectGOPATH(p.AbsRoot) // If p.AbsRoot is a not symlink, attempt to detect GOPATH for p.AbsRoot only. - if equal, _ := fs.EqualPaths(p.AbsRoot, p.ResolvedAbsRoot); equal { + if equal, _ := fs.EquivalentPaths(p.AbsRoot, p.ResolvedAbsRoot); equal { return pGOPATH, perr } @@ -191,7 +191,7 @@ func (c *Ctx) DetectProjectGOPATH(p *Project) (string, error) { } // If pGOPATH equals rGOPATH, then both are within the same GOPATH. - if equal, _ := fs.EqualPaths(pGOPATH, rGOPATH); equal { + if equal, _ := fs.EquivalentPaths(pGOPATH, rGOPATH); equal { return "", errors.Errorf("both %s and %s are in the same GOPATH %s", p.AbsRoot, p.ResolvedAbsRoot, pGOPATH) } diff --git a/internal/fs/fs.go b/internal/fs/fs.go index e1b00d1c52..096b0dbfed 100644 --- a/internal/fs/fs.go +++ b/internal/fs/fs.go @@ -102,9 +102,9 @@ func HasFilepathPrefix(path, prefix string) bool { return true } -// EqualPaths compares the paths passed to check if the are equivalent. +// EquivalentPaths compares the paths passed to check if the are equivalent. // It respects the case-sensitivity of the underlaying filesysyems. -func EqualPaths(p1, p2 string) (bool, error) { +func EquivalentPaths(p1, p2 string) (bool, error) { p1 = filepath.Clean(p1) p2 = filepath.Clean(p2) diff --git a/internal/fs/fs_test.go b/internal/fs/fs_test.go index 3731f24a27..a82058378e 100644 --- a/internal/fs/fs_test.go +++ b/internal/fs/fs_test.go @@ -134,7 +134,7 @@ func TestHasFilepathPrefix_Files(t *testing.T) { } } -func TestEqualPaths(t *testing.T) { +func TestEquivalentPaths(t *testing.T) { h := test.NewHelper(t) h.TempDir("dir") h.TempDir("dir2") @@ -166,17 +166,17 @@ func TestEqualPaths(t *testing.T) { } for _, tc := range testcases { - got, err := EqualPaths(tc.p1, tc.p2) + got, err := EquivalentPaths(tc.p1, tc.p2) if err != nil && !tc.err { t.Error("unexpected error:", err) } if caseSensitive { if tc.caseSensitiveEquivalent != got { - t.Errorf("expected EqualPaths(%q, %q) to be %t on case-sensitive filesystem, got %t", tc.p1, tc.p2, tc.caseSensitiveEquivalent, got) + t.Errorf("expected EquivalentPaths(%q, %q) to be %t on case-sensitive filesystem, got %t", tc.p1, tc.p2, tc.caseSensitiveEquivalent, got) } } else { if tc.caseInensitiveEquivalent != got { - t.Errorf("expected EqualPaths(%q, %q) to be %t on case-insensitive filesystem, got %t", tc.p1, tc.p2, tc.caseInensitiveEquivalent, got) + t.Errorf("expected EquivalentPaths(%q, %q) to be %t on case-insensitive filesystem, got %t", tc.p1, tc.p2, tc.caseInensitiveEquivalent, got) } } }