aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/internal/run/run.go
AgeCommit message (Collapse)Author
2021-07-30[dev.cmdgo] cmd/internal/str: move package from cmd/go/internal/strJay Conrod
This will let cmd/cgo and cmd/link use this package for argument parsing. For golang/go#41400 Change-Id: I12ee21151bf3f00f3e8d427faaaab2453c823117 Reviewed-on: https://go-review.googlesource.com/c/go/+/334730 Trust: Jay Conrod <jayconrod@google.com> Reviewed-by: Michael Matloob <matloob@golang.org>
2021-07-26[dev.cmdgo] cmd/go: add the workspace modeMichael Matloob
This change adds the outline of the implementation of the workspace mode. The go command will now locate go.work files, and read them to determine which modules are in the workspace. It will then put those modules in the root of the workspace when building the build list. It supports building, running, testing, and listing in workspaces. There are still many TODOs for undone work and other changes to fix certain cases. Some of these undone parts include: replaces and go.work.sum files, as well as go mod {test,why,verify}, excludes in workspaces, updating work files to include module names in comments and setting the GOWORK variable. For #45713 Change-Id: I72716af7a300a2896087fc8a79c04e951d248278 Reviewed-on: https://go-review.googlesource.com/c/go/+/334934 Trust: Michael Matloob <matloob@golang.org> Run-TryBot: Michael Matloob <matloob@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-04-16cmd/go: fix mod_install_pkg_versionJay Conrod
mainPackagesOnly now includes non-main packages matched by literal arguments in the returned slice, since their errors must be reported. GoFilesPackages attaches the same error to its package if opts.MainOnly is true. This changes the error output of 'go run' slightly, but it seems like an imporovement. For #42088 Change-Id: I8f2942470383af5d4c9763022bc94338f5314b07 Reviewed-on: https://go-review.googlesource.com/c/go/+/310829 Trust: Jay Conrod <jayconrod@google.com> Run-TryBot: Jay Conrod <jayconrod@google.com> Reviewed-by: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-04-16cmd/go: support 'go run cmd@version'Jay Conrod
'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>
2021-04-16cmd/go/internal/load: convert two global flags to an options structJay Conrod
PackageOpts is a new struct type accepted by package loading functions. It initially has two fields: IgnoreImports, and ModResolveTests. Previously, these were global variables set by clients. We'll add more to this in the future. For #40775 Change-Id: I6956e56502de836d3815ce788bdf16fc5f3e5338 Reviewed-on: https://go-review.googlesource.com/c/go/+/310669 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>
2021-03-04cmd/go: clarify errors for commands run outside a moduleJay Conrod
The new error message tells the user what was wrong (no go.mod found) and directs them to 'go help modules', which links to tutorials. Fixes #44745 Change-Id: I98f31fec4a8757eb1792b45491519da4c552cb0f Reviewed-on: https://go-review.googlesource.com/c/go/+/298650 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>
2020-08-20cmd/go: do context propagation for tracing downloadsMichael Matloob
This change does context propagation (and only context propagation) necessary to add context to modfetch.Download and pkg.LoadImport. This was done by adding context to their callers, and then adding context to all call-sites, and then repeating adding context to callers of those enclosing functions and their callers until none were left. In some cases the call graph expansion was pruned by using context.TODOs. The next CL will add a span to Download. I kept it out of this change to avoid making it any larger (and harder to review) than it needs to be. Updates #38714 Change-Id: I7a03416e04a14ca71636d96f2c1bda2c4c30d348 Reviewed-on: https://go-review.googlesource.com/c/go/+/249021 Run-TryBot: Michael Matloob <matloob@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
2020-08-18cmd/go: revert 3 CLs affecting par.Work, context propagation, tracingDmitri Shuralyov
This reverts the following changes: • cmd/go: add tracing for querying and downloading from the proxy CL 242786, commit 1a3558341860357c2400e37773e5076bb3a51628 • cmd/go: do context propagation for tracing downloads CL 248327, commit c0cf190d226cc3defb71d17c01d0b45bf49a8a85 • cmd/go/internal: remove some users of par.Work CL 248326, commit f30044a03bc7cf107dbec03c02fb6d0072878252 Reason for revert: broke linux 386 and amd64 longtest builders. The problem started with CL 248326, but CL 248327 and CL 242786 are reverted as well due to conflicts. Updates #38714. Fixes #40861. Change-Id: I68496b4e5a27e47a42183553c3a645b288edac83 Reviewed-on: https://go-review.googlesource.com/c/go/+/249017 Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com> Reviewed-by: Carlos Amedee <carlos@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-08-17cmd/go: do context propagation for tracing downloadsMichael Matloob
This change does context propagation (and only context propagation) necessary to add context to modfetch.Download and pkg.LoadImport. This was done by adding context to their callers, and then adding context to all call-sites, and then repeating adding context to callers of those enclosing functions and their callers until none were left. In some cases the call graph expansion was pruned by using context.TODOs. The next CL will add a span to Download. I kept it out of this change to avoid making it any larger (and harder to review) than it needs to be. Updates #38714 Change-Id: I5bf2d599aafef67334c384dfccd5e255198c85b4 Reviewed-on: https://go-review.googlesource.com/c/go/+/248327 Run-TryBot: Michael Matloob <matloob@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-08-17cmd/go: propagate context into Action.Func callsMichael Matloob
Action.Func is now a func(*Builder, context.Context, *Action), so that contexts can be propagated into the action funcs. While context is traditionally the first parameter of a function, it's the second parameter of Action.Func's type to continue to allow for methods on Builder to be used as functions taking a *Builder as the first parameter. context.Context is instead the first parameter on those functions. Change-Id: I5f058d6a99a1e96fe2025f2e8ce30a033d12e935 Reviewed-on: https://go-review.googlesource.com/c/go/+/248321 Run-TryBot: Michael Matloob <matloob@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-08-12cmd/go: propagate context into PackagesForBuild and Do for tracingMichael Matloob
This change propagates context into PackagesForErrors and Do for the purpose of tracing, and calls trace.StartSpan on PackagesForErrors and Do, so that the trace now shows the broad outline of where the "Loading" and "Execution" phases are in the build. Updates #38714 Change-Id: Ib9a7cf7030210f68f76663d1c8a7461e0a226611 Reviewed-on: https://go-review.googlesource.com/c/go/+/238541 Run-TryBot: Michael Matloob <matloob@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-08-12cmd/go: add Context parameter to base.command.RunMichael Matloob
One small step to start propagating the context in cmd/go for tracing purposes. Updates #38714 Change-Id: Ibb6debeb9233f84d55f0e81244487355cbe7b82c Reviewed-on: https://go-review.googlesource.com/c/go/+/237684 Run-TryBot: Michael Matloob <matloob@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2019-10-09all: remove the nacl port (part 1)Brad Fitzpatrick
You were a useful port and you've served your purpose. Thanks for all the play. A subsequent CL will remove amd64p32 (including assembly files and toolchain bits) and remaining bits. The amd64p32 removal will be separated into its own CL in case we want to support the Linux x32 ABI in the future and want our old amd64p32 support as a starting point. Updates #30439 Change-Id: Ia3a0c7d49804adc87bf52a4dea7e3d3007f2b1cd Reviewed-on: https://go-review.googlesource.com/c/go/+/199499 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-10-04cmd/go: remove the -mod flag from 'go get'Bryan C. Mills
'GOFLAGS=-mod=vendor' currently causes 'go get' to always fail unless the '-mod' flag is explicitly overwritten. Moreover, as of CL 198319 we plan to set -mod=vendor by default if a vendor directory is present, so all users with vendor directories will be affected — not just those who set 'GOFLAGS' explicitly. Similarly, an explicit '-mod=readonly' argument to 'go get' is currently ignored as a special case, but the fact that it is ignored (rather than rejected) can be very surprising. Rather than adding more special cases, we should remove the '-mod' flag from 'go get' entirely. Fixes #30345 Fixes #32502 Updates #33848 Change-Id: Iecd3233ca3ef580ca3a66bd5e6ee8d86d4cbd8a7 Reviewed-on: https://go-review.googlesource.com/c/go/+/198438 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
2019-04-30cmd/go: derive executable name from package path in 'go run'Liberatys
Change name of temporary executable on go run . to directory name. Fixes #31571 Change-Id: I0a0ce74154e76205bb43805c95bd7fb8fd2dfd01 GitHub-Last-Rev: e0964983e18a1d45b55f7098c7489059708c7e5e GitHub-Pull-Request: golang/go#31614 Reviewed-on: https://go-review.googlesource.com/c/go/+/173297 Run-TryBot: Jay Conrod <jayconrod@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
2019-03-27cmd/go/internal/{run,work,generate}: document file path location requirementAgniva De Sarker
Mention that .go files must be from a single directory for them to be treated as a single package. Fixes #21529 Change-Id: I79cb08b9f43888814b1249a7b50bc7bc70bc1c72 Reviewed-on: https://go-review.googlesource.com/c/go/+/149797 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2018-11-14cmd/go: don't panic when go run is passed ... under nonexistent dirMark Rushakoff
Given a nonexistent directory above a wildcard: go run ./nonexistent/... Print this error instead of panicking: go run: no packages loaded from ./nonexistent/... Fixes #28696. Change-Id: Iaa3bc5c78b14ef858d931778e1bc55ca626c5571 GitHub-Last-Rev: bb1a80483ad26c8cf646cf0900d08cfe49aba535 GitHub-Pull-Request: golang/go#28703 Reviewed-on: https://go-review.googlesource.com/c/148821 Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2018-08-01cmd/go: split go mod into multiple subcommandsRuss Cox
The current "go mod" command does too many things. The design is unclear. It looks like "everything you might want to do with modules" which causes people to think all module operations go through "go mod", which is the opposite of the seamless integration we're going for. In particular too many people think "go mod -require" and "go get" are the same. It does make sense to put the module-specific functionality under "go mod", but not as flags. Instead, split "go mod" into multiple subcommands: go mod edit # old go mod -require ... go mod fix # old go mod -fix go mod graph # old go mod -graph go mod init # old go mod -init go mod tidy # old go mod -sync go mod vendor # old go mod -vendor go mod verify # old go mod -verify Splitting out the individual commands makes both the docs and the implementations dramatically easier to read. It simplifies the command lines (go mod -init -module m is now 'go mod init m') and allows command-specific flags. We've avoided subcommands in the go command to date, and we should continue to avoid adding them unless it really makes the experience significantly better. In this case, it does. Creating subcommands required some changes in the core command-parsing and help logic to generalize from one level to multiple levels. As part of having "go mod init" be a separate command, this CL changes the failure behavior during module initialization to be delayed until modules are actually needed. Initialization can still happen early, but the base.Fatalf is delayed until something needs to use modules. This fixes a bunch of commands like 'go env' that were unhelpfully failing with GO111MODULE=on when not in a module directory. Fixes #26432. Fixes #26581. Fixes #26596. Fixes #26639. Change-Id: I868db0babe8c288e8af684b29d4a5ae4825d6407 Reviewed-on: https://go-review.googlesource.com/126655 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2018-05-10cmd/go: add support for 'go run pkg' or 'go run .'Russ Cox
To date, go run has required a list of .go files. This CL allows in place of that list a single import path or a directory name or a pattern matching a single patckage. This allows 'go run pkg' or 'go run dir', most importantly 'go run .'. The discussion in #22726 gives more motivation. The basic idea is that you can already run 'go test .' but if you're developing a command it's pretty awkward to iterate at the same speed. This lets you do that, by using 'go run . [args]'. Fixes #22726. Change-Id: Ibfc8172a4f752588ad96df0a6b0928e9b61fa27f Reviewed-on: https://go-review.googlesource.com/109341 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2018-02-17cmd/go: document 'go run' exit codesYury Smolsky
Updated docs that go run does not return the exit code of the compiled binary. Fixes #23716 Change-Id: Ib85459974c4c6d2760ddba957ef711628098661f Reviewed-on: https://go-review.googlesource.com/94795 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-11-07cmd/go: accept relative -pkgdir argumentRuss Cox
Fixes #21309. Change-Id: I8ff1b0f37e34a3a4e9f8448d66a64fe3863d081f Reviewed-on: https://go-review.googlesource.com/76250 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Rob Pike <r@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-10-12cmd/go: delete p.Internal.Target in favor of p.TargetRuss Cox
The two are not meaningfully different, and it is confusing to have two. Change-Id: Ie6a355ea4d79fb4bb79bf5124071a866038b19ba Reviewed-on: https://go-review.googlesource.com/70211 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-10-11cmd/go: clean up compile vs link vs shared library actionsRuss Cox
Everything got a bit tangled together in b.action1. Try to tease things apart again. In general this is a refactoring of the existing code, with limited changes to the effect of the code. The main additional change is to complete a.Deps for link actions. That list now directly contains all the inputs the linker will attempt to read, eliminating the need for a transitive traversal of the entire action graph to find those. The comepleteness of a.Deps will be important when we eventually use it to decide whether an cached action output can be reused. all.bash passes, but it's possible I've broken some subtety of buildmode=shared again. Certainly that code took the longest to get working. Change-Id: I34e849eda446dca45a9cfce02b07bec6edb6d0d4 Reviewed-on: https://go-review.googlesource.com/69831 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-10-10cmd/go: add undocumented -debug-actiongraph flag to dump action graphRuss Cox
This will be useful for debugging but is intentionally undocumented and not guaranteed to persist in any particular form. Change-Id: I60710a1e94cfc2ce31fe91fc268c51985060f8df Reviewed-on: https://go-review.googlesource.com/69330 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: David Crawshaw <crawshaw@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-29cmd/go: build test binaries with -s in addition to -wRuss Cox
Fixes #19753. Change-Id: Ib20a69b1d0bcc42aa9e924918bcb578d6a560a31 Reviewed-on: https://go-review.googlesource.com/38742 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-02-03cmd/go: address review commentsRuss Cox
Address review comments from earlier CLs. These are changes I was too scared to try to push down into the original CLs (thanks, Git). Change-Id: I0e428fad73d71bd2a7d08178cf2e856de3cef19f Reviewed-on: https://go-review.googlesource.com/36257 Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-02-03cmd/go: split out ↵Russ Cox
cmd/go/internal/clean,doc,fix,generate,list,run,tool,version,vet This is one CL in a long sequence of changes to break up the go command from one package into a plausible group of packages. This sequence is concerned only with moving code, not changing or cleaning up code. There will still be more cleanup after this sequence. The entire sequence will be submitted together: it is not a goal for the tree to build at every step. For #18653. Change-Id: Ib22fc435827d4a05a77a5200ac437ce00e2a4da3 Reviewed-on: https://go-review.googlesource.com/36204 Reviewed-by: David Crawshaw <crawshaw@golang.org>