Fixed path check that could end up in infinite loop on Windows
diff --git a/cmd/tree.go b/cmd/tree.go index dac864b..252405e 100644 --- a/cmd/tree.go +++ b/cmd/tree.go
@@ -195,7 +195,15 @@ abs = cwd } if abs != "." { - for wd := abs; wd != "/"; wd = filepath.Dir(wd) { + + // Previously there was a check on the loop that wd := "/". The path + // "/" is a POSIX path so this fails on Windows. Now the check is to + // make sure the same wd isn't seen twice. When the same wd happens + // more than once it's the beginning of looping on the same location + // which is the top level. + pwd := "" + for wd := abs; wd != pwd; wd = filepath.Dir(wd) { + pwd = wd // Don't look for packages outside the GOPATH // Note, the GOPATH may or may not end with the path separator.