Skip to content

Commit

Permalink
Cleanup: simplify switch statement, reuse build.IsLocalImport
Browse files Browse the repository at this point in the history
We already import and use build package here, so there's no harm in
reuse. The code is both shorter and more readable.
  • Loading branch information
rtfb committed Aug 14, 2017
1 parent d6140bd commit 0e41a07
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions internal/gps/pkgtree/pkgtree.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,11 @@ func ListPackages(fileRoot, importRoot string) (PackageTree, error) {
// see any.
var lim []string
for _, imp := range append(pkg.Imports, pkg.TestImports...) {
switch {
// Do allow the single-dot, at least for now
case imp == "..":
lim = append(lim, imp)
case strings.HasPrefix(imp, "./"):
lim = append(lim, imp)
case strings.HasPrefix(imp, "../"):
if build.IsLocalImport(imp) {
// Do allow the single-dot, at least for now
if imp == "." {
continue
}
lim = append(lim, imp)
}
}
Expand Down

0 comments on commit 0e41a07

Please sign in to comment.