From: Ian Alexander Date: Wed, 8 Oct 2025 23:56:51 +0000 (-0400) Subject: cmd/go: use local state object in `bug.runBug` X-Git-Tag: go1.26rc1~495 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=9926e1124e5dd6397f16f36456aedbee101bc6f3;p=gostls13.git cmd/go: use local state object in `bug.runBug` 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 LUCI-TryBot-Result: Go LUCI Reviewed-by: Michael Matloob --- diff --git a/src/cmd/go/internal/bug/bug.go b/src/cmd/go/internal/bug/bug.go index 637673f7eb..749edc51cf 100644 --- a/src/cmd/go/internal/bug/bug.go +++ b/src/cmd/go/internal/bug/bug.go @@ -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()