mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/go: use local state object in env.runEnv
This commit modifies `env.runEnv` 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/envcmd
rf '
add env.go:/func runEnv\(/-0 var moduleLoaderState *modload.State
ex {
import "cmd/go/internal/modload";
modload.LoaderState -> moduleLoaderState
}
add runEnv://+0 moduleLoaderState := modload.NewState()
rm env.go:/var moduleLoaderState \*modload.State/
'
Change-Id: I1177df5d09a6ee642eade6cfa4278bb1629843a8
Reviewed-on: https://go-review.googlesource.com/c/go/+/711131
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>
This commit is contained in:
parent
f2dd3d7e31
commit
26a8a21d7f
1 changed files with 4 additions and 3 deletions
|
|
@ -272,6 +272,7 @@ func argKey(arg string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func runEnv(ctx context.Context, cmd *base.Command, args []string) {
|
func runEnv(ctx context.Context, cmd *base.Command, args []string) {
|
||||||
|
moduleLoaderState := modload.NewState()
|
||||||
if *envJson && *envU {
|
if *envJson && *envU {
|
||||||
base.Fatalf("go: cannot use -json with -u")
|
base.Fatalf("go: cannot use -json with -u")
|
||||||
}
|
}
|
||||||
|
|
@ -306,7 +307,7 @@ func runEnv(ctx context.Context, cmd *base.Command, args []string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
env := cfg.CmdEnv
|
env := cfg.CmdEnv
|
||||||
env = append(env, ExtraEnvVars(modload.LoaderState)...)
|
env = append(env, ExtraEnvVars(moduleLoaderState)...)
|
||||||
|
|
||||||
if err := fsys.Init(); err != nil {
|
if err := fsys.Init(); err != nil {
|
||||||
base.Fatal(err)
|
base.Fatal(err)
|
||||||
|
|
@ -336,8 +337,8 @@ func runEnv(ctx context.Context, cmd *base.Command, args []string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if needCostly {
|
if needCostly {
|
||||||
work.BuildInit(modload.LoaderState)
|
work.BuildInit(moduleLoaderState)
|
||||||
env = append(env, ExtraEnvVarsCostly(modload.LoaderState)...)
|
env = append(env, ExtraEnvVarsCostly(moduleLoaderState)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(args) > 0 {
|
if len(args) > 0 {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue