Commit 8765e89a authored by Baokun Lee's avatar Baokun Lee Committed by Bryan C. Mills

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: default avatarBryan C. Mills <bcmills@google.com>
parent 35435b27
...@@ -183,7 +183,7 @@ func runEdit(cmd *base.Command, args []string) { ...@@ -183,7 +183,7 @@ func runEdit(cmd *base.Command, args []string) {
} }
if *editModule != "" { if *editModule != "" {
modFile.AddModuleStmt(modload.CmdModModule) modFile.AddModuleStmt(*editModule)
} }
if *editGo != "" { if *editGo != "" {
......
...@@ -42,6 +42,12 @@ go mod edit -fmt # without -print, should write file (and nothing to stdout) ...@@ -42,6 +42,12 @@ go mod edit -fmt # without -print, should write file (and nothing to stdout)
! stdout . ! stdout .
cmpenv go.mod $WORK/go.mod.edit6 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 -- -- x.go --
package x package x
...@@ -159,3 +165,7 @@ exclude x.1 v1.2.0 ...@@ -159,3 +165,7 @@ exclude x.1 v1.2.0
replace x.1 => y.1/v2 v2.3.6 replace x.1 => y.1/v2 v2.3.6
require x.3 v1.99.0 require x.3 v1.99.0
-- $WORK/m/go.mod.edit --
module x.x/y/z
go $goversion
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment