Fix: Support for x.y versions

This commit is contained in:
aarzilli 2015-08-12 13:37:36 +02:00 committed by Derek Parker
parent f0f6fa6b2e
commit 77d46a51fb
2 changed files with 7 additions and 3 deletions

@ -33,11 +33,14 @@ func parseVersionString(ver string) (GoVersion, bool) {
vr = strings.SplitN(v[1], "rc", 2)
if len(vr) == 2 {
r.RC, err3 = strconv.Atoi(vr[1])
}
}
if len(vr) < 2 {
} else {
r.Minor, err2 = strconv.Atoi(v[1])
if err2 != nil {
return GoVersion{}, false
}
return r, true
}
}
r.Minor, err2 = strconv.Atoi(vr[0])
r.Rev = -1

@ -668,6 +668,7 @@ func versionAfterOrEqual(t *testing.T, verStr string, ver GoVersion) {
}
func TestParseVersionString(t *testing.T) {
versionAfterOrEqual(t, "go1.4", GoVersion{1, 4, 0, 0, 0})
versionAfterOrEqual(t, "go1.5.0", GoVersion{1, 5, 0, 0, 0})
versionAfterOrEqual(t, "go1.4.2", GoVersion{1, 4, 2, 0, 0})
versionAfterOrEqual(t, "go1.5beta2", GoVersion{1, 5, -1, 2, 0})