diff options
author | Jay Conrod <jayconrod@google.com> | 2019-12-19 13:00:28 -0500 |
---|---|---|
committer | Jay Conrod <jayconrod@google.com> | 2019-12-19 19:52:21 +0000 |
commit | 0f834bb77e11d1ca1f06fc925f5bd7e44c7f4867 (patch) | |
tree | ac6d40a65679207c9d6827cb509ecbcbf387c42f /src/cmd/go/testdata/script/modfile_flag.txt | |
parent | a197c7bbf2bee9c7078e821736e81f9642548443 (diff) | |
download | go-0f834bb77e11d1ca1f06fc925f5bd7e44c7f4867.tar.gz go-0f834bb77e11d1ca1f06fc925f5bd7e44c7f4867.zip |
cmd/go: in 'go list -m', print effective go.mod file
When the -modfile flag is in use (either explicitly or from GOFLAGS),
'go list -m' will now print the effective go.mod file for the main
module in the GoMod field in -f or -json output.
Fixes #36220
Updates #34506
Change-Id: I89c2ee40f20e07854bb37c6e4e13eeea0cce7b0d
Reviewed-on: https://go-review.googlesource.com/c/go/+/212100
Run-TryBot: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Diffstat (limited to 'src/cmd/go/testdata/script/modfile_flag.txt')
-rw-r--r-- | src/cmd/go/testdata/script/modfile_flag.txt | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/cmd/go/testdata/script/modfile_flag.txt b/src/cmd/go/testdata/script/modfile_flag.txt index 1409be9599..f05bf03fbf 100644 --- a/src/cmd/go/testdata/script/modfile_flag.txt +++ b/src/cmd/go/testdata/script/modfile_flag.txt @@ -11,6 +11,15 @@ cp go.sum go.sum.orig go mod init example.com/m grep example.com/m go.alt.mod +# 'go env GOMOD' should print the path to the real file. +# 'go env' does not recognize the '-modfile' flag. +go env GOMOD +stdout '^\$WORK[/\\]gopath[/\\]src[/\\]go.mod$' + +# 'go list -m' should print the effective go.mod file as GoMod though. +go list -m -f '{{.GoMod}}' +stdout '^go.alt.mod$' + # go mod edit should operate on the alternate file go mod edit -require rsc.io/quote@v1.5.2 grep rsc.io/quote go.alt.mod |