fix(nix/buildGo/external): Properly match import path prefixes

Prior to this patch, github.com/hashicorp/terraform-svchost is
erroneously considered a sub-package of github.com/hashicorp/terraform,
breaking dependency searching:

    error: missing local dependency 'github.com.hashicorp.terraform-svchost' in 'github.com/hashicorp/terraform'

Change-Id: Ibcf0f3a9b1742ce46f84cbbf84e90127b8c1df0d
Reviewed-on: https://cl.tvl.fyi/c/depot/+/122
Reviewed-by: tazjin <mail@tazj.in>
This commit is contained in:
edef 2020-06-03 03:42:59 +00:00
parent e09c4a0ae8
commit 01ddbb4397

View file

@ -97,7 +97,7 @@ func analysePackage(root, source, importpath string, stdlib map[string]bool) (pk
if i == importpath { if i == importpath {
local = append(local, []string{}) local = append(local, []string{})
} else if strings.HasPrefix(i, importpath) { } else if strings.HasPrefix(i, importpath+"/") {
local = append(local, strings.Split(strings.TrimPrefix(i, importpath+"/"), "/")) local = append(local, strings.Split(strings.TrimPrefix(i, importpath+"/"), "/"))
} else { } else {
foreign = append(foreign, i) foreign = append(foreign, i)