From: Michael Matloob Date: Mon, 10 Jan 2022 17:58:20 +0000 (-0500) Subject: cmd/go: run go install in workspace mode X-Git-Tag: go1.18beta2~102 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=3ff12a019f00bc81996c453e5cb4729a9278f65a;p=gostls13.git cmd/go: run go install in workspace mode It's too confusing to users to run go install in module mode, so run it in workspace mode instead. Fixes #50036 Change-Id: Ia99927bd98f54be4c42224a247543892045e3464 Reviewed-on: https://go-review.googlesource.com/c/go/+/377334 Reviewed-by: Bryan Mills Trust: Michael Matloob Run-TryBot: Michael Matloob TryBot-Result: Gopher Robot --- diff --git a/src/cmd/go/internal/work/build.go b/src/cmd/go/internal/work/build.go index 9d0ad27f0d..9b1acf987d 100644 --- a/src/cmd/go/internal/work/build.go +++ b/src/cmd/go/internal/work/build.go @@ -617,6 +617,7 @@ func runInstall(ctx context.Context, cmd *base.Command, args []string) { } } + modload.InitWorkfile() BuildInit() pkgs := load.PackagesAndErrors(ctx, load.PackageOpts{}, args) if cfg.ModulesEnabled && !modload.HasModRoot() { diff --git a/src/cmd/go/testdata/script/work_install_submodule.txt b/src/cmd/go/testdata/script/work_install_submodule.txt new file mode 100644 index 0000000000..3d1171736d --- /dev/null +++ b/src/cmd/go/testdata/script/work_install_submodule.txt @@ -0,0 +1,36 @@ +# This is a regression test for golang.org/issue/50036 +# Don't check sums for other modules in the workspace. + +cd m/sub +go install -n + +-- go.work -- +go 1.18 + +use ( + ./m + ./m/sub +) +-- m/go.mod -- +module example.com/m + +go 1.18 + +-- m/m.go -- +package m + +func M() {} +-- m/sub/go.mod -- +module example.com/m/sub + +go 1.18 + +require example.com/m v1.0.0 +-- m/sub/main.go -- +package main + +import "example.com/m" + +func main() { + m.M() +}