diff options
author | Jay Conrod <jayconrod@google.com> | 2021-04-13 18:00:09 -0400 |
---|---|---|
committer | Jay Conrod <jayconrod@google.com> | 2021-04-16 16:11:09 +0000 |
commit | 04e1176fd288f1ceba987d8d2fd9040e45157b38 (patch) | |
tree | 10ec3e608b04147d8eb3939d8a7b230700f22d15 /src/cmd/go/alldocs.go | |
parent | 639cb1b629e575487af78bb3f60af24a7df7a3f7 (diff) | |
download | go-04e1176fd288f1ceba987d8d2fd9040e45157b38.tar.gz go-04e1176fd288f1ceba987d8d2fd9040e45157b38.zip |
cmd/go: support 'go run cmd@version'
'go run' can now build a command at a specific version in module-aware
mode, ignoring the go.mod file in the current directory if there is one.
For #42088
Change-Id: I0bd9bcbe40c0442a268cd1cc315a8a2cbb5adeee
Reviewed-on: https://go-review.googlesource.com/c/go/+/310074
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Diffstat (limited to 'src/cmd/go/alldocs.go')
-rw-r--r-- | src/cmd/go/alldocs.go | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/cmd/go/alldocs.go b/src/cmd/go/alldocs.go index 66e78bb1ac..999fcf7e53 100644 --- a/src/cmd/go/alldocs.go +++ b/src/cmd/go/alldocs.go @@ -1315,10 +1315,21 @@ // go run [build flags] [-exec xprog] package [arguments...] // // Run compiles and runs the named main Go package. -// Typically the package is specified as a list of .go source files from a single directory, -// but it may also be an import path, file system path, or pattern +// Typically the package is specified as a list of .go source files from a single +// directory, but it may also be an import path, file system path, or pattern // matching a single known package, as in 'go run .' or 'go run my/cmd'. // +// If the package argument has a version suffix (like @latest or @v1.0.0), +// "go run" builds the program in module-aware mode, ignoring the go.mod file in +// the current directory or any parent directory, if there is one. This is useful +// for running programs without affecting the dependencies of the main module. +// +// If the package argument doesn't have a version suffix, "go run" may run in +// module-aware mode or GOPATH mode, depending on the GO111MODULE environment +// variable and the presence of a go.mod file. See 'go help modules' for details. +// If module-aware mode is enabled, "go run" runs in the context of the main +// module. +// // By default, 'go run' runs the compiled binary directly: 'a.out arguments...'. // If the -exec flag is given, 'go run' invokes the binary using xprog: // 'xprog a.out arguments...'. |