Skip to content

Commit b15a553

Browse files
dmitshurgopherbot
authored andcommitted
internal/telemetry: use go/version.IsValid instead of checking for "X:"
This simplification is viable as the module requires Go 1.23.0 by now. Also add a test case for Go development versions after CL 668015. For golang/go#68579. Change-Id: I8e78d3cce927437537622e1cc06d64157c46b056 Reviewed-on: https://go-review.googlesource.com/c/telemetry/+/669396 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Reviewed-by: Cherry Mui <[email protected]> Auto-Submit: Dmitri Shuralyov <[email protected]> Reviewed-by: Michael Matloob <[email protected]>
1 parent f36df2b commit b15a553

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

go.mod

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ module golang.org/x/telemetry
22

33
go 1.23.0
44

5-
require golang.org/x/mod v0.24.0
6-
75
require (
6+
golang.org/x/mod v0.24.0
87
golang.org/x/sync v0.14.0
98
golang.org/x/sys v0.33.0
109
)

internal/telemetry/proginfo.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package telemetry
66

77
import (
8+
"go/version"
89
"os"
910
"path/filepath"
1011
"runtime/debug"
@@ -26,9 +27,7 @@ func IsToolchainProgram(progPath string) bool {
2627
// special characters.
2728
func ProgramInfo(info *debug.BuildInfo) (goVers, progPath, progVers string) {
2829
goVers = info.GoVersion
29-
// TODO(matloob): Use go/version.IsValid instead of checking for X: once the telemetry
30-
// module can be upgraded to require Go 1.22.
31-
if strings.Contains(goVers, "devel") || strings.Contains(goVers, "-") || strings.Contains(goVers, "X:") {
30+
if strings.Contains(goVers, "devel") || strings.Contains(goVers, "-") || !version.IsValid(goVers) {
3231
goVers = "devel"
3332
}
3433

internal/telemetry/proginfo_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ func TestProgramInfo_GoVersion(t *testing.T) {
8383
"go1.23.0",
8484
"go1.23.0",
8585
},
86+
{
87+
"go1.25-devel_9ce47e66e8 Wed Mar 26 03:48:50 2025 -0700",
88+
"devel",
89+
},
8690
{
8791
"devel go1.24-0d6bb68f48 Thu Jul 25 23:27:41 2024 -0600",
8892
"devel",

0 commit comments

Comments
 (0)