mirror of
https://github.com/golang/go
synced 2024-11-27 00:21:21 -07:00
cmd/go/internal/modcmd: fix go mod edit -module replaces empty string
Fixes golang/go#28820. Change-Id: Id931617efcf161ec934eb6d44062ad95e8a6ab8d Reviewed-on: https://go-review.googlesource.com/c/150277 Run-TryBot: Baokun Lee <nototon@gmail.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
This commit is contained in:
parent
35435b27c4
commit
8765e89a8a
@ -183,7 +183,7 @@ func runEdit(cmd *base.Command, args []string) {
|
||||
}
|
||||
|
||||
if *editModule != "" {
|
||||
modFile.AddModuleStmt(modload.CmdModModule)
|
||||
modFile.AddModuleStmt(*editModule)
|
||||
}
|
||||
|
||||
if *editGo != "" {
|
||||
|
10
src/cmd/go/testdata/script/mod_edit.txt
vendored
10
src/cmd/go/testdata/script/mod_edit.txt
vendored
@ -42,6 +42,12 @@ go mod edit -fmt # without -print, should write file (and nothing to stdout)
|
||||
! stdout .
|
||||
cmpenv go.mod $WORK/go.mod.edit6
|
||||
|
||||
# go mod edit -module
|
||||
cd $WORK/m
|
||||
go mod init a.a/b/c
|
||||
go mod edit -module x.x/y/z
|
||||
cmpenv go.mod go.mod.edit
|
||||
|
||||
-- x.go --
|
||||
package x
|
||||
|
||||
@ -159,3 +165,7 @@ exclude x.1 v1.2.0
|
||||
replace x.1 => y.1/v2 v2.3.6
|
||||
|
||||
require x.3 v1.99.0
|
||||
-- $WORK/m/go.mod.edit --
|
||||
module x.x/y/z
|
||||
|
||||
go $goversion
|
Loading…
Reference in New Issue
Block a user