Add info on whether a pkg is vendored in glide list
This addresses issue #91.
diff --git a/cmd/tree.go b/cmd/tree.go
index 39d4d8c..ccde8f2 100644
--- a/cmd/tree.go
+++ b/cmd/tree.go
@@ -53,7 +53,7 @@
return nil, err
}
- direct := map[string]bool{}
+ direct := map[string]*pinfo{}
d := walkDeps(buildContext, basedir, myName)
for _, i := range d {
listDeps(buildContext, direct, i, basedir)
@@ -69,26 +69,30 @@
sort.Strings(sortable)
for _, k := range sortable {
- dec := "no"
- if direct[k] {
- dec = "yes"
+ dec := "yes"
+ if d, ok := direct[k]; ok && d.PType == ptypeUnknown {
+ dec = "no"
}
- fmt.Printf("%s (Present: %s)\n", k, dec)
+ vendored := "no"
+ if d, ok := direct[k]; ok && d.PType == ptypeVendor {
+ vendored = "yes"
+ }
+ fmt.Printf("%s (Present: %s, Vendored: %s)\n", k, dec, vendored)
}
return nil, nil
}
-func listDeps(b *BuildCtxt, info map[string]bool, name, path string) {
+func listDeps(b *BuildCtxt, info map[string]*pinfo, name, path string) {
found := findPkg(b, name, path)
switch found.PType {
case ptypeUnknown:
- info[name] = false
+ info[name] = found
break
case ptypeGoroot, ptypeCgo:
break
default:
- info[name] = true
+ info[name] = found
for _, i := range walkDeps(b, found.Path, found.Name) {
listDeps(b, info, i, found.Path)
}
@@ -127,6 +131,7 @@
type pinfo struct {
Name, Path string
PType ptype
+ Vendored bool
}
func findPkg(b *BuildCtxt, name, cwd string) *pinfo {
@@ -144,6 +149,7 @@
if fi, err = os.Stat(p); err == nil && (fi.IsDir() || isLink(fi)) {
info.Path = p
info.PType = ptypeVendor
+ info.Vendored = true
return info
}
}