Merge pull request #487 from hori-ryota/feature/fix-unknown-packageroot
Fix NormalizeName for subpackage of unknown host
diff --git a/util/normalizename_test.go b/util/normalizename_test.go
index c6f4d02..d5a454b 100644
--- a/util/normalizename_test.go
+++ b/util/normalizename_test.go
@@ -31,11 +31,18 @@
extra: "",
},
{
+ input: "otherurl/example/root/sub",
+ root: "otherurl/example/root",
+ extra: "sub",
+ },
+ {
input: "net",
root: "net",
extra: "",
},
}
+ remotePackageCache["otherurl/example/root"] = "otherurl/example/root"
+
for _, test := range packages {
root, extra := NormalizeName(test.input)
if root != test.root {
diff --git a/util/util.go b/util/util.go
index a5b346f..f0854d2 100644
--- a/util/util.go
+++ b/util/util.go
@@ -110,7 +110,7 @@
func checkRemotePackageCache(pkg string) (string, bool) {
for k, v := range remotePackageCache {
- if pkg == k {
+ if pkg == k || strings.HasPrefix(pkg, k + "/") {
return v, true
}
}
@@ -290,7 +290,7 @@
out, err := exec.Command(goExecutable, "env", "GOROOT").Output()
if goRoot = strings.TrimSpace(string(out)); len(goRoot) == 0 || err != nil {
return nil, fmt.Errorf("Please set the $GOROOT environment " +
- "variable to use this command\n")
+ "variable to use this command\n")
}
buildContext.GOROOT = goRoot
}