Skip to content
This repository has been archived by the owner on Feb 26, 2019. It is now read-only.

Commit

Permalink
Trim 'rc' out of go version strings when determining major version.
Browse files Browse the repository at this point in the history
  • Loading branch information
Edward Muller committed Jan 28, 2016
1 parent 64044a2 commit 3020345
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
11 changes: 9 additions & 2 deletions dep.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions dep_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"runtime"
)

const version = 51
const version = 52

var cmdVersion = &Command{
Name: "version",
Expand Down

0 comments on commit 3020345

Please sign in to comment.