mirror of https://github.com/golang/go.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 <bcmills@google.com> Trust: Michael Matloob <matloob@golang.org> Run-TryBot: Michael Matloob <matloob@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
ce01afe907
commit
3ff12a019f
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
}
|
||||
Loading…
Reference in New Issue