]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go/internal/telemetrystats: handle cases where there's no patch
authorMichael Matloob <matloob@golang.org>
Thu, 23 May 2024 14:28:58 +0000 (10:28 -0400)
committerMichael Matloob <matloob@golang.org>
Thu, 23 May 2024 17:38:57 +0000 (17:38 +0000)
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 <samthanawalla@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Than McIntosh <thanm@google.com>
src/cmd/go/internal/telemetrystats/version_unix.go

index 952f27e2b385e1bfa5e574c281c3ea32f81a9ce6..fbf4292312eb25d1adbc700fcd58a79a72fc854a 100644 (file)
@@ -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
 }