]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: use local state for telemetry
authorIan Alexander <jitsu@google.com>
Fri, 10 Oct 2025 12:52:30 +0000 (08:52 -0400)
committerIan Alexander <jitsu@google.com>
Mon, 27 Oct 2025 20:29:10 +0000 (13:29 -0700)
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 <matloob@golang.org>
Reviewed-by: Michael Matloob <matloob@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/cmd/go/internal/telemetrystats/telemetrystats.go

index 077c2d817f0e144d2d134db5a2162eb73d4c0494..84b4ae2e8415673bb043a182f67979b4d9580553 100644 (file)
@@ -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")