diff --git a/Changelog.md b/Changelog.md index 9bc7d69..6274191 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,7 @@ +# v52 2016/01/27 + +* Trim 'rc' out of go version strings when determining major version. + # v51 2016/01/21 * Trim 'beta' out of go version strings when determining major version. diff --git a/dep.go b/dep.go index 22d3c35..8b74760 100644 --- a/dep.go +++ b/dep.go @@ -77,8 +77,15 @@ func trimGoVersion(version string) (string, error) { if len(p) < 2 { return "", fmt.Errorf("Error determing major go version from: %q", version) } - if strings.Contains(p[1], "beta") { - p[1] = strings.Split(p[1], "beta")[0] + var split string + switch { + case strings.Contains(p[1], "beta"): + split = "beta" + case strings.Contains(p[1], "rc"): + split = "rc" + } + if split != "" { + p[1] = strings.Split(p[1], split)[0] } return p[0] + "." + p[1], nil } diff --git a/dep_test.go b/dep_test.go index 3c2ee59..27527ff 100644 --- a/dep_test.go +++ b/dep_test.go @@ -9,6 +9,7 @@ func TestTrimGoVersion(t *testing.T) { }{ {in: "go1.5", out: "go1.5", err: false}, {in: "go1.5beta1", out: "go1.5", err: false}, + {in: "go1.6rc1", out: "go1.6", err: false}, {in: "go1.5.1", out: "go1.5", err: false}, {in: "devel", out: "devel", err: false}, {in: "boom", out: "", err: true}, diff --git a/version.go b/version.go index aaf0aaf..aa5d57e 100644 --- a/version.go +++ b/version.go @@ -5,7 +5,7 @@ import ( "runtime" ) -const version = 51 +const version = 52 var cmdVersion = &Command{ Name: "version",