From 139f89226f0fd066347a1235202a92038959e00c Mon Sep 17 00:00:00 2001 From: Ian Alexander Date: Fri, 10 Oct 2025 08:52:30 -0400 Subject: [PATCH] cmd/go: use local state for telemetry This change adds a new loader state to satisfy the requirements for the (currently unused) telemetry stats for the go command. This commit is part of the overall effort to eliminate global modloader state. Change-Id: I6d4e38c91e5413d7649dfc6301e3ba35ee36c9b9 Reviewed-on: https://go-review.googlesource.com/c/go/+/711136 Reviewed-by: Michael Matloob Reviewed-by: Michael Matloob LUCI-TryBot-Result: Go LUCI --- src/cmd/go/internal/telemetrystats/telemetrystats.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cmd/go/internal/telemetrystats/telemetrystats.go b/src/cmd/go/internal/telemetrystats/telemetrystats.go index 077c2d817f..84b4ae2e84 100644 --- a/src/cmd/go/internal/telemetrystats/telemetrystats.go +++ b/src/cmd/go/internal/telemetrystats/telemetrystats.go @@ -22,9 +22,12 @@ func Increment() { // incrementConfig increments counters for the configuration // the command is running in. func incrementConfig() { - if !modload.WillBeEnabled(modload.LoaderState) { + // TODO(jitsu): Telemetry for the go/mode counters should eventually be + // moved to modload.Init() + s := modload.NewState() + if !modload.WillBeEnabled(s) { counter.Inc("go/mode:gopath") - } else if workfile := modload.FindGoWork(modload.LoaderState, base.Cwd()); workfile != "" { + } else if workfile := modload.FindGoWork(s, base.Cwd()); workfile != "" { counter.Inc("go/mode:workspace") } else { counter.Inc("go/mode:module") -- 2.52.0