From bbf3a418a5a119e2ab6aaaf1e04f42caa1b683a8 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Thu, 12 Dec 2019 22:58:51 +0000 Subject: [PATCH] feat(external): Add fully qualified import path to analyser output This is used by Nix to build the derivation names for individual packages. --- external/main.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/external/main.go b/external/main.go index 028703e38..aac966172 100644 --- a/external/main.go +++ b/external/main.go @@ -29,7 +29,8 @@ var stdlibList string // Return information includes the local (relative from project root) // and external (none-stdlib) dependencies of this package. type pkg struct { - Name []string `json:"name"` + Name string `json:"name"` + Locator []string `json:"locator"` Files []string `json:"files"` LocalDeps [][]string `json:"localDeps"` ForeignDeps []string `json:"foreignDeps"` @@ -95,12 +96,12 @@ func analysePackage(root, source, importpath string, stdlib map[string]bool) (pk prefix := strings.TrimPrefix(source, root+"/") - name := []string{} + locator := []string{} if len(prefix) != len(source) { - name = strings.Split(prefix, "/") + locator = strings.Split(prefix, "/") } else { - // Otherwise, the name is empty since its the root package and no - // prefix should be added to files. + // Otherwise, the locator is empty since its the root package and + // no prefix should be added to files. prefix = "" } @@ -110,7 +111,8 @@ func analysePackage(root, source, importpath string, stdlib map[string]bool) (pk } return pkg{ - Name: name, + Name: path.Join(importpath, prefix), + Locator: locator, Files: files, LocalDeps: local, ForeignDeps: foreign,