diff --git a/proc/arch.go b/proc/arch.go index 7fedbc54..fd716745 100644 --- a/proc/arch.go +++ b/proc/arch.go @@ -37,7 +37,7 @@ func (a *AMD64) SetGStructOffset(ver GoVersion, isextld bool) { a.gStructOffset = 0x8a0 case "linux": a.gStructOffset = 0xfffffffffffffff0 - if isextld || ver.AfterOrEqual(GoVersion{1, 5, -1, 2}) || ver.IsDevel() { + if isextld || ver.AfterOrEqual(GoVersion{1, 5, -1, 2, 0}) || ver.IsDevel() { a.gStructOffset += 8 } } diff --git a/proc/go_version.go b/proc/go_version.go index 752c8d64..88a89b96 100644 --- a/proc/go_version.go +++ b/proc/go_version.go @@ -10,6 +10,7 @@ type GoVersion struct { Minor int Rev int Beta int + RC int } func parseVersionString(ver string) (GoVersion, bool) { @@ -17,7 +18,7 @@ func parseVersionString(ver string) (GoVersion, bool) { var err1, err2, err3 error if strings.HasPrefix(ver, "devel") { - return GoVersion{-1, 0, 0, 0}, true + return GoVersion{-1, 0, 0, 0, 0}, true } if strings.HasPrefix(ver, "go") { @@ -25,14 +26,21 @@ func parseVersionString(ver string) (GoVersion, bool) { switch len(v) { case 2: r.Major, err1 = strconv.Atoi(v[0]) - v = strings.SplitN(v[1], "beta", 2) - if len(v) != 2 { + vr := strings.SplitN(v[1], "beta", 2) + if len(vr) == 2 { + r.Beta, err3 = strconv.Atoi(vr[1]) + } else { + vr = strings.SplitN(v[1], "rc", 2) + if len(vr) == 2 { + r.RC, err3 = strconv.Atoi(vr[1]) + } + } + if len(vr) < 2 { return GoVersion{}, false } - r.Minor, err2 = strconv.Atoi(v[0]) + r.Minor, err2 = strconv.Atoi(vr[0]) r.Rev = -1 - r.Beta, err3 = strconv.Atoi(v[1]) if err1 != nil || err2 != nil || err3 != nil { return GoVersion{}, false @@ -82,6 +90,10 @@ func (a *GoVersion) AfterOrEqual(b GoVersion) bool { return false } + if a.RC < b.RC { + return false + } + return true } diff --git a/proc/proc_test.go b/proc/proc_test.go index 4f7225c8..d02d4cb0 100644 --- a/proc/proc_test.go +++ b/proc/proc_test.go @@ -668,9 +668,10 @@ func versionAfterOrEqual(t *testing.T, verStr string, ver GoVersion) { } func TestParseVersionString(t *testing.T) { - versionAfterOrEqual(t, "go1.5.0", GoVersion{1, 5, 0, 0}) - versionAfterOrEqual(t, "go1.4.2", GoVersion{1, 4, 2, 0}) - versionAfterOrEqual(t, "go1.5beta2", GoVersion{1, 5, -1, 2}) + 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}) + versionAfterOrEqual(t, "go1.5rc2", GoVersion{1, 5, -1, 0, 2}) ver, ok := parseVersionString("devel +17efbfc Tue Jul 28 17:39:19 2015 +0000 linux/amd64") if !ok { t.Fatalf("Could not parse devel version string")