1
0
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:
Baokun Lee 2018-11-20 00:40:28 +08:00 committed by Bryan C. Mills
parent 35435b27c4
commit 8765e89a8a
2 changed files with 11 additions and 1 deletions

View File

@ -183,7 +183,7 @@ func runEdit(cmd *base.Command, args []string) {
}
if *editModule != "" {
modFile.AddModuleStmt(modload.CmdModModule)
modFile.AddModuleStmt(*editModule)
}
if *editGo != "" {

View File

@ -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