Fixing bug where lookup of package was taking too long.
diff --git a/cmd/tree.go b/cmd/tree.go index 60181ec..ecd4435 100644 --- a/cmd/tree.go +++ b/cmd/tree.go
@@ -195,6 +195,11 @@ } if abs != "." { for wd := abs; wd != "/"; wd = filepath.Dir(wd) { + + // Don't look for packages outside the GOPATH + if wd == b.GOPATH { + break + } p = filepath.Join(wd, "vendor", name) if fi, err = os.Stat(p); err == nil && (fi.IsDir() || isLink(fi)) { info.Path = p
diff --git a/cmd/yaml.go b/cmd/yaml.go index ef41087..4432a86 100644 --- a/cmd/yaml.go +++ b/cmd/yaml.go
@@ -5,6 +5,7 @@ "io" "io/ioutil" "os" + "path/filepath" "strings" "github.com/Masterminds/cookoo" @@ -155,6 +156,18 @@ // For example, golang.org/x/crypto/ssh becomes golang.org/x/crypto. 'ssh' is // returned as extra data. func NormalizeName(name string) (string, string) { + + // Fastpath check if a name in the GOROOT. There is an issue when a pkg + // is in the GOROOT and GetRootFromPackage tries to look it up because it + // expects remote names. + b, err := GetBuildContext() + if err == nil { + p := filepath.Join(b.GOROOT, "src", name) + if _, err := os.Stat(p); err == nil { + return name, "" + } + } + root := util.GetRootFromPackage(name) extra := strings.TrimPrefix(name, root) if len(extra) > 0 && extra != "/" {
diff --git a/glide.lock b/glide.lock index a61af79..7bd39fd 100644 --- a/glide.lock +++ b/glide.lock
@@ -1,10 +1,10 @@ hash: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 -updated: 2015-12-07T11:25:07.016186764-05:00 +updated: 2015-12-09T10:30:35.945332257-05:00 imports: - name: github.com/codegangsta/cli version: 0302d3914d2a6ad61404584cdae6e6dbc9c03599 - name: github.com/Masterminds/cookoo - version: 623f8762b2474f1ad6c2cac6bf331b8871591379 + version: 78aa11ce75e257c51be7ea945edb84cf19c4a6de repo: git@github.com:Masterminds/cookoo.git vcs: git subpackages: