Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions dependency/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -1032,23 +1032,23 @@ func (r *Resolver) FindPkg(name string) *PkgInfo {
//}
//}

// Check $GOPATH
for _, rr := range filepath.SplitList(r.BuildContext.GOPATH) {
// Check $GOROOT
for _, rr := range filepath.SplitList(r.BuildContext.GOROOT) {
p = filepath.Join(rr, "src", filepath.FromSlash(name))
if pkgExists(p) {
info.Path = p
info.Loc = LocGopath
info.Loc = LocGoroot
r.findCache[name] = info
return info
}
}

// Check $GOROOT
for _, rr := range filepath.SplitList(r.BuildContext.GOROOT) {
// Check $GOPATH
for _, rr := range filepath.SplitList(r.BuildContext.GOPATH) {
p = filepath.Join(rr, "src", filepath.FromSlash(name))
if pkgExists(p) {
info.Path = p
info.Loc = LocGoroot
info.Loc = LocGopath
r.findCache[name] = info
return info
}
Expand Down
13 changes: 13 additions & 0 deletions dependency/resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@ func TestResolveLocalShallow(t *testing.T) {
}

func TestResolveLocalDeep(t *testing.T) {
// create package of same name with sys package
err := os.MkdirAll(filepath.Join(os.Getenv("GOPATH"), "src/strings"), os.ModePerm)
if err != nil {
t.Fatalf("Failed to create package of test case: %s", err)
}
// remove package of same name with sys package
defer func() {
err = os.Remove(filepath.Join(os.Getenv("GOPATH"), "src/strings"))
if err != nil {
t.Fatalf("Failed to remove package of test case: %s", err)
}
}()

r, err := NewResolver("../")
if err != nil {
t.Fatal(err)
Expand Down