aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/internal/modcmd/edit.go
diff options
context:
space:
mode:
authorJay Conrod <jayconrod@google.com>2019-10-22 11:30:20 -0400
committerJay Conrod <jayconrod@google.com>2019-10-24 20:15:50 +0000
commitc357b363cf1027afe3296e973ea6f6613cc757ad (patch)
tree089677a31fcbabaccf4e5c6172c103529a0b0975 /src/cmd/go/internal/modcmd/edit.go
parentc4c37547b12f113d07b987881a81c1dbc754cd66 (diff)
downloadgo-c357b363cf1027afe3296e973ea6f6613cc757ad.tar.gz
go-c357b363cf1027afe3296e973ea6f6613cc757ad.zip
cmd/go: add -modfile flag that sets go.mod file to read/write
This change adds the -modfile flag to module aware build commands and to 'go mod' subcommands. -modfile may be set to a path to an alternate go.mod file to be read and written. A real go.mod file must still exist and is used to set the module root directory. However, it is not opened. When -modfile is set, the effective location of the go.sum file is also changed to the -modfile with the ".mod" suffix trimmed (if present) and ".sum" added. Updates #34506 Change-Id: I2d1e044e18af55505a4f24bbff09b73bb9c908b4 Reviewed-on: https://go-review.googlesource.com/c/go/+/202564 Run-TryBot: Jay Conrod <jayconrod@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
Diffstat (limited to 'src/cmd/go/internal/modcmd/edit.go')
-rw-r--r--src/cmd/go/internal/modcmd/edit.go3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/cmd/go/internal/modcmd/edit.go b/src/cmd/go/internal/modcmd/edit.go
index 239f88bdc2..97cc0fa02f 100644
--- a/src/cmd/go/internal/modcmd/edit.go
+++ b/src/cmd/go/internal/modcmd/edit.go
@@ -12,7 +12,6 @@ import (
"fmt"
"io/ioutil"
"os"
- "path/filepath"
"strings"
"cmd/go/internal/base"
@@ -159,7 +158,7 @@ func runEdit(cmd *base.Command, args []string) {
if len(args) == 1 {
gomod = args[0]
} else {
- gomod = filepath.Join(modload.ModRoot(), "go.mod")
+ gomod = modload.ModFilePath()
}
if *editModule != "" {