]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go/internal/modcmd: fix go mod edit -module replaces empty string
authorBaokun Lee <nototon@gmail.com>
Mon, 19 Nov 2018 16:40:28 +0000 (00:40 +0800)
committerBryan C. Mills <bcmills@google.com>
Wed, 5 Dec 2018 20:10:21 +0000 (20:10 +0000)
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>
src/cmd/go/internal/modcmd/edit.go
src/cmd/go/testdata/script/mod_edit.txt

index f13fe249937dea01288c0d0039f9fc2522e98509..5066e4ddf75f97394c44549dda8113f72f7ca32e 100644 (file)
@@ -183,7 +183,7 @@ func runEdit(cmd *base.Command, args []string) {
        }
 
        if *editModule != "" {
-               modFile.AddModuleStmt(modload.CmdModModule)
+               modFile.AddModuleStmt(*editModule)
        }
 
        if *editGo != "" {
index 61801d5021bf2a8334b5c633ebf6855bef71fc76..aa714e8b3cd7baeb6cc6a9e7862d05a92dad2ec2 100644 (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
\ No newline at end of file