From: Michael Matloob Date: Thu, 23 May 2024 14:28:58 +0000 (-0400) Subject: cmd/go/internal/telemetrystats: handle cases where there's no patch X-Git-Tag: go1.23rc1~155 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=c34c124f4007e79978674ba519b9421665060186;p=gostls13.git cmd/go/internal/telemetrystats: handle cases where there's no patch If there's no second dot assume the version is just a major.minor. Change-Id: I765d6e8d7c1e63c695a0a3b0c047d86b989f95d9 Reviewed-on: https://go-review.googlesource.com/c/go/+/587796 Reviewed-by: Sam Thanawalla LUCI-TryBot-Result: Go LUCI Reviewed-by: Than McIntosh --- diff --git a/src/cmd/go/internal/telemetrystats/version_unix.go b/src/cmd/go/internal/telemetrystats/version_unix.go index 952f27e2b3..fbf4292312 100644 --- a/src/cmd/go/internal/telemetrystats/version_unix.go +++ b/src/cmd/go/internal/telemetrystats/version_unix.go @@ -33,13 +33,15 @@ func incrementVersionCounters() { return } major, minor, ok := majorMinor(convert(v.Release[:])) + if runtime.GOOS == "aix" { + major, minor, ok = convert(v.Version[:]), convert(v.Release[:]), ok + } if !ok { telemetry.Inc(fmt.Sprintf("go/platform/host/%s/version:unknown-bad-format", runtime.GOOS)) return } telemetry.Inc(fmt.Sprintf("go/platform/host/%s/major-version:%s", runtime.GOOS, major)) telemetry.Inc(fmt.Sprintf("go/platform/host/%s/version:%s-%s", runtime.GOOS, major, minor)) - } func majorMinor(v string) (string, string, bool) { @@ -49,7 +51,10 @@ func majorMinor(v string) (string, string, bool) { } major := v[:firstDot] v = v[firstDot+len("."):] - secondDot := strings.Index(v, ".") - minor := v[:secondDot] + endMinor := strings.IndexAny(v, ".-_") + if endMinor < 0 { + endMinor = len(v) + } + minor := v[:endMinor] return major, minor, true }