about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--external/main.go18
1 files changed, 13 insertions, 5 deletions
diff --git a/external/main.go b/external/main.go
index 0c1d84d5b723..028703e38cad 100644
--- a/external/main.go
+++ b/external/main.go
@@ -94,19 +94,27 @@ func analysePackage(root, source, importpath string, stdlib map[string]bool) (pk
 	}
 
 	prefix := strings.TrimPrefix(source, root+"/")
+
+	name := []string{}
+	if len(prefix) != len(source) {
+		name = strings.Split(prefix, "/")
+	} else {
+		// Otherwise, the name is empty since its the root package and no
+		// prefix should be added to files.
+		prefix = ""
+	}
+
 	files := []string{}
 	for _, f := range p.GoFiles {
 		files = append(files, path.Join(prefix, f))
 	}
 
-	analysed := pkg{
-		Name:        strings.Split(prefix, "/"),
+	return pkg{
+		Name:        name,
 		Files:       files,
 		LocalDeps:   local,
 		ForeignDeps: foreign,
-	}
-
-	return analysed, nil
+	}, nil
 }
 
 func loadStdlibPkgs(from string) (pkgs map[string]bool, err error) {