1
0
mirror of https://github.com/golang/go synced 2024-11-26 22:01:27 -07:00

cmd/go/internal/module: fix validation for module paths ending with /v

Unlike "/v1", "/v" is not likely to be mistaken for a semantic import path.

Change-Id: I024647d78c79c7761b98ddeccdc7e259ca94b568
Reviewed-on: https://go-review.googlesource.com/c/152738
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
Bryan C. Mills 2018-12-05 10:20:24 -05:00
parent 6ff8c1db0b
commit 5b48ab8881
2 changed files with 2 additions and 1 deletions

View File

@ -284,7 +284,7 @@ func SplitPathVersion(path string) (prefix, pathMajor string, ok bool) {
}
i--
}
if i <= 1 || path[i-1] != 'v' || path[i-2] != '/' {
if i <= 1 || i == len(path) || path[i-1] != 'v' || path[i-2] != '/' {
return path, "", true
}
prefix, pathMajor = path[:i-2], path[i-2:]

View File

@ -214,6 +214,7 @@ var splitPathVersionTests = []struct {
{"x.y/z", ""},
{"x.y/z", "/v2"},
{"x.y/z", "/v3"},
{"x.y/v", ""},
{"gopkg.in/yaml", ".v0"},
{"gopkg.in/yaml", ".v1"},
{"gopkg.in/yaml", ".v2"},