]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: use local state object in `bug.runBug`
authorIan Alexander <jitsu@google.com>
Wed, 8 Oct 2025 23:56:51 +0000 (19:56 -0400)
committerIan Alexander <jitsu@google.com>
Sat, 25 Oct 2025 01:08:21 +0000 (18:08 -0700)
This commit modifies `bug.runBug` to construct a new modload.State
object using the new constructor instead of the current global
`modload.LoaderState` variable.

This commit is part of the overall effort to eliminate global
modloader state.

[git-generate]
cd src/cmd/go/internal/bug
rf '
  add bug.go:/func runBug\(/-0 var moduleLoaderState *modload.State
  ex {
    import "cmd/go/internal/modload";
    modload.LoaderState -> moduleLoaderState
  }
  add runBug://+0 moduleLoaderState := modload.NewState()
  rm bug.go:/var moduleLoaderState \*modload.State/
'

Change-Id: Ic4f74d2127f667491136ee4bad4388b4d606821e
Reviewed-on: https://go-review.googlesource.com/c/go/+/711123
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@google.com>
src/cmd/go/internal/bug/bug.go

index 637673f7ebd33dbffb13ef277b7d4541986fb89b..749edc51cf1d0330790b6508f25089d59683cb52 100644 (file)
@@ -42,16 +42,17 @@ func init() {
 }
 
 func runBug(ctx context.Context, cmd *base.Command, args []string) {
+       moduleLoaderState := modload.NewState()
        if len(args) > 0 {
                base.Fatalf("go: bug takes no arguments")
        }
-       work.BuildInit(modload.LoaderState)
+       work.BuildInit(moduleLoaderState)
 
        var buf strings.Builder
        buf.WriteString(bugHeader)
        printGoVersion(&buf)
        buf.WriteString("### Does this issue reproduce with the latest release?\n\n\n")
-       printEnvDetails(modload.LoaderState, &buf)
+       printEnvDetails(moduleLoaderState, &buf)
        buf.WriteString(bugFooter)
 
        body := buf.String()