Skip to content

Commit 9926e11

Browse files
committed
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 <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Michael Matloob <[email protected]>
1 parent 2c4fd7b commit 9926e11

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/cmd/go/internal/bug/bug.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,17 @@ func init() {
4242
}
4343

4444
func runBug(ctx context.Context, cmd *base.Command, args []string) {
45+
moduleLoaderState := modload.NewState()
4546
if len(args) > 0 {
4647
base.Fatalf("go: bug takes no arguments")
4748
}
48-
work.BuildInit(modload.LoaderState)
49+
work.BuildInit(moduleLoaderState)
4950

5051
var buf strings.Builder
5152
buf.WriteString(bugHeader)
5253
printGoVersion(&buf)
5354
buf.WriteString("### Does this issue reproduce with the latest release?\n\n\n")
54-
printEnvDetails(modload.LoaderState, &buf)
55+
printEnvDetails(moduleLoaderState, &buf)
5556
buf.WriteString(bugFooter)
5657

5758
body := buf.String()

0 commit comments

Comments
 (0)