summaryrefslogtreecommitdiff
path: root/src/cmd/go
Commit message (Collapse)AuthorAgeFilesLines
* cmd: update vendored golang.org/x/modDmitri Shuralyov2023-05-171-0/+34
| | | | | | | | | | | | | | | | | | | | Pull in CL 492990. This teaches 'go mod tidy' and other go subcommands that write go.mod files to use semantic sort for exclude blocks, gated on said files declaring Go version 1.21 or higher. go get golang.org/x/mod@e7bea8f1d64f # includes CL 492990 go mod tidy go mod vendor Fixes #60028. Change-Id: Ia9342dcc23cd68de068a70657b59c25f69afa381 Reviewed-on: https://go-review.googlesource.com/c/go/+/494578 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
* cmd/go: prune more dependencies in 'go get'Bryan C. Mills2023-05-1713-537/+1100
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Prior to this change, 'go get' pulled in every version of each module whose path is explicitly listed in the go.mod file. When graph pruning is enabled (that is, when the main module is at 'go 1.17' or higher), that pulled in transitive dependencies of older-than-selected versions of dependencies, which are normally pruned out by other 'go' commands (including 'go mod tidy' and 'go mod graph'). To make matters worse, different parts of `go get` were making different assumptions about which kinds of conflicts would be reported: the modget package assumed that any conflict is necessarily due to some explicit constraint, but 'go get' was imposing an additional constraint that modules could not be incidentally upgraded in the course of a downgrade. When that additional constraint failed, the modload package reported the failure as though it were a real (caller-supplied) constraint, confusing the caller (which couldn't identify any specific package or argument that caused the failure). This change fixes both of those problems by replacing the modload.EditRequirements algorithm with a different one. The new algorithm is, roughly, as follows. 1. Propose a list of “root requirements” to be written to the updated go.mod file. 2. Load the module graph from those requirements mostly as usual, but if any root is upgraded due to transitive dependencies, retain the original roots and the paths leading from those roots to the upgrades. (This forms an “extended graph”, in which we can trace a path from to each version that appears in the graph starting at one or more of the original roots.) 3. Identify which roots caused any module path to be upgraded above its passed-in version constraint. For each such root, either report an unresolvable conflict (if the root itself is constrained to a specific version) or identify an updated version to propose: either a downgrade to the next-highest version, or an upgrade to the actually-selected version of the root (if that version is allowed). To avoid looping forever or devolving into an NP-complete search, we never propose a version that was already rejected previously, regardless of what other roots were present alongside it at the time. 4. If the version of any root was changed, repeat from (1). This algorithm is guaranteed to terminate, because there are finitely many root versions and we permanently reject at least one each time we downgrade its path to a lower version. In addition, this change implements support for the '-v' flag to log more information about version changes at each iteration. Fixes #56494. Fixes #55955. Change-Id: Iebc17dd7586594d5732e228043c3c4c6da230f44 Reviewed-on: https://go-review.googlesource.com/c/go/+/471595 TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Michael Matloob <matloob@golang.org>
* cmd/go: add a test that reproduces the root cause of issue #56494Bryan C. Mills2023-05-172-1/+137
| | | | | | | | | | | For #56494. Change-Id: I9bbded6d014ac73d81b973f2d7b4783e64380031 Reviewed-on: https://go-review.googlesource.com/c/go/+/447797 Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Michael Matloob <matloob@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com>
* cmd/go/internal/modload: replace import error message from goroot to stdjchen0382023-05-158-14/+14
| | | | | | | | | | | | | | | When importing a package that does not exist, it would show goroot error message and path. We would like to replace goroot with std instead. Fixes #56965. Change-Id: I86f8a7fab6555b68f792a3a4686de20d51eced8b Reviewed-on: https://go-review.googlesource.com/c/go/+/453895 Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
* cmd/go/internal/modindex: update index_format.txtBryan C. Mills2023-05-132-8/+14
| | | | | | | | | | | | | | | | This incorporates the changes from CL 453603 and CL 416178. Please review carefully: I did my best to read through the CLs, but I'm not entirely confident I haven't made a mistake. Fixes #59770. Change-Id: Ib8937e55dcd11e3f75c16b28519d3d91df1d4da3 Reviewed-on: https://go-review.googlesource.com/c/go/+/492596 Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org>
* cmd/go: add a regression test for Git configurations with ↵Bryan C. Mills2023-05-121-0/+19
| | | | | | | | | | | | safe.bareRepository=explicit Change-Id: I394265a4bf849ec89ac44c67aeaaaca801e46caa Reviewed-on: https://go-review.googlesource.com/c/go/+/493476 Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Emily Shaffer <emilyshaffer@google.com> Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/go/internal/modload: reject the -modfile flag in workspace modeZeke Lu2023-05-127-14/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, in workspace mode, the -modfile flag affects all the modules listed in the go.work file. This is not desirable most of the time. And when it results in an error, the error message does not help. For example, when there are more than one modules listed in the go.work file, running "go list -m -modfile=path/to/go.mod" gives this error: go: module example.com/foo appears multiple times in workspace This change reject -modfile flag explicitly with this error message: go: -modfile cannot be used in workspace mode While at here, correct some typos in the modload package. Fixes #59996. Change-Id: Iff4cd9f3974ea359889dd713a747b6932cf42dfd GitHub-Last-Rev: 7dbc9c3f2f9bfe8acab088eb3266a08d8ec1ba16 GitHub-Pull-Request: golang/go#60033 Reviewed-on: https://go-review.googlesource.com/c/go/+/493315 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com>
* cmd/go: diff .so files quietly in TestScript/build_plugin_reproducibleDmitri Shuralyov2023-05-121-1/+1
| | | | | | | | | | | | | | | This avoids printing verbose binary data and making bell sounds when the test fails. The binary data can be inspected via other means if needed. For #58557. Change-Id: Ia1c4f2c6b9ff2cf6f97611cf335b978fc7bb201f Reviewed-on: https://go-review.googlesource.com/c/go/+/494577 Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com>
* cmd/go: fix swigOne action with -nAustin Clements2023-05-121-2/+7
| | | | | | | | | | | | | | Currently, if cmd/go builds a swig file with the -n (dry run) flag, it will print the swig command invocation without executing it, but then attempt to actually rename one of swig's output files, which will fail. Make this rename conditional on -n. While we're here, we fix the missing logging of the rename command with -x, too. Change-Id: I1f6e6efc53dfe4ac5a42d26096679b97bc322827 Reviewed-on: https://go-review.googlesource.com/c/go/+/493255 Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* misc/cgo: move easy tests to cmd/cgo/internalAustin Clements2023-05-122-2/+2
| | | | | | | | | | | | | | | | | | | This moves most misc/cgo tests to cmd/cgo/internal. This is mostly a trivial rename and updating dist/test.go for the new paths, plus excluding these packages from regular dist test registration. A few tests were sensitive to what path they ran in, so we update those. This will let these tests access facilities in internal/testenv. For #37486. Change-Id: I3ed417c7c22d9b667f2767c0cb1f59118fcd4af6 Reviewed-on: https://go-review.googlesource.com/c/go/+/492720 Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/go/internal: update documentation of go test and go generateShogo Hida2023-05-103-0/+18
| | | | | | | | | | | | | | Fixes #57050 Change-Id: I46cac667ff78ac171c878f4366f8f01f58f1d27d GitHub-Last-Rev: 697c255ece18cd4772b76d62991474a7da2536d8 GitHub-Pull-Request: golang/go#57814 Reviewed-on: https://go-review.googlesource.com/c/go/+/461683 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
* cmd/go/internal/modload: skip reading go.mod files for imports in 'go mod ↵Bryan C. Mills2023-05-103-7/+34
| | | | | | | | | | | | | | | | | | | | | | | | tidy' of modules before 'go 1.21' This eliminate a network access in 'go mod tidy' of an already-tidy module, which would otherwise be needed to fetch go.mod checksums for the test dependencies whose go.mod checksums were omitted in Go releases between Go 1.17 and 1.20 due to bug #56222. For modules between 'go 1.17' and 'go 1.20' we intentionally preserve the old 'go mod tidy' output (omitting go.sum entries for the go.mod files of test dependencies of external packages). We should also avoid performing extra sumdb lookups for checksums that would be discarded anyway. Updates #56222. Change-Id: I7f0f1c8e902db0e3414c819621c4b99052f503f0 Reviewed-on: https://go-review.googlesource.com/c/go/+/492741 Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Carlos Amedee <carlos@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/go: fix cgo prefix mapping for non-vendored modulesqmuntal2023-05-091-1/+1
| | | | | | | | | | | Regression introduced in CL 478455. Change-Id: I8083a0accb047188dde1a3d408df2aafaf4a5356 Reviewed-on: https://go-review.googlesource.com/c/go/+/493835 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
* cmd: go get golang.org/x/tools@8f7fb01dd429 and revendorRuss Cox2023-05-092-3/+3
| | | | | | | | | | | | | | | | | | go get golang.org/x/tools@8f7fb01dd429 # CL 493619 go mod tidy go mod vendor The goal is to set up for importing the bisect command, for use in tests, in a follow-up CL. This also updates x/sys and x/net, including in std, because x/tools now depends on newer versions of those. Change-Id: I24c283cc165464d9c873ba7a9a4e75a9d02919b2 Reviewed-on: https://go-review.googlesource.com/c/go/+/493596 Reviewed-by: Alan Donovan <adonovan@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Russ Cox <rsc@golang.org>
* cmd/go/internal/envcmd: on unix pass script contents directly to sh -cMichael Matloob2023-05-081-6/+5
| | | | | | | | | | | | | Instead of writing them to a file and executing that file. For #59998 Change-Id: I341786926762359f67dccb475295afbbb8ed1054 Reviewed-on: https://go-review.googlesource.com/c/go/+/493555 Run-TryBot: Michael Matloob <matloob@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
* cmd/go/internal/modfetch/codehost: explicitly specify GIT_DIREmily Shaffer2023-05-081-0/+2
| | | | | | | | | | | | | | | | | | | | | When Git has safe.bareRepository=explicit set, operations on bare Git repositories will fail unless --git-dir or GIT_DIR is set. The rest of the time, specifying the gitdir makes repository discovery at the beginning of a Git command ever-so-slightly faster. So, there is no downside to ensuring that users with this stricter security config set can still use 'go mod' commands easily. See https://lore.kernel.org/git/pull.1261.v8.git.git.1657834081.gitgitgadget@gmail.com/ for a more detailed description of security concerns around embedded bare repositories without an explicitly specified GIT_DIR. Change-Id: I01c1d97a79fdab12c2b5532caf84eb7760f96b18 Reviewed-on: https://go-review.googlesource.com/c/go/+/489915 Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com>
* cmd/go: save checksums for go.mod files needed for go version linesBryan C. Mills2023-05-0516-24/+131
| | | | | | | | | | | | | | | | | | | | | | When we load a package from a module, we need the go version line from that module's go.mod file to know what language semantics to use for the package. We need to save a checksum for the go.mod file even if the module's requirements are pruned out of the module graph. Previously, we were missing checksums for test dependencies of packages in 'all' and packages passed to 'go get -t'. This change preserves the existing bug for 'go mod tidy' in older module versions, but fixes it for 'go mod tidy' in modules at go 1.21 or higher and for 'go get -t' at all versions. Fixes #56222. Change-Id: Icd6acce348907621ae0b02dbeac04fb180353dcf Reviewed-on: https://go-review.googlesource.com/c/go/+/489075 Reviewed-by: Michael Matloob <matloob@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com>
* cmd/go: sanitize go env outputsMichael Matloob2023-05-054-3/+158
| | | | | | | | | | | | | | | | | | | go env, without any arguments, outputs the environment variables in the form of a script that can be run on the host OS. On Unix, single quote the strings and place single quotes themselves outside the single quoted strings. On windows use the set "var=val" syntax with the quote starting before the variable. Fixes #58508 Change-Id: Iecd379a4af7285ea9b2024f0202250c74fd9a2bd Reviewed-on: https://go-review.googlesource.com/c/go/+/488375 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Damien Neil <dneil@google.com> Run-TryBot: Michael Matloob <matloob@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
* cmd/go/internal/modfetch/codehost: skip tests that fail due to tag mismatchesBryan C. Mills2023-05-051-0/+6
| | | | | | | | | | | For #56881. Change-Id: If9d8fa2942e4dd8da5e673631cdc277e0fe6c962 Reviewed-on: https://go-review.googlesource.com/c/go/+/492975 Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/go: fix short tests on iosBryan C. Mills2023-05-045-10/+37
| | | | | | | | | | | | | As of CL 488076, many cmd/go tests can run on the ios-arm64-corellium builder. Some of them had made erroneous assumptions about cmd/go's use of the C toolchain. Change-Id: Ib59d9858ef3930de2b412daa4462b72065f69cfd Reviewed-on: https://go-review.googlesource.com/c/go/+/492597 Reviewed-by: Michael Matloob <matloob@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com>
* all: add String for fs.{FileInfo,DirEntry} implementationsIan Lance Taylor2023-05-042-0/+16
| | | | | | | | | | | | | | | | | The new String methods use the new FormatFileInfo and FormatDirEntry functions. Fixes #54451 Change-Id: I414cdfc212ec3c316fb2734756d2117842a23631 Reviewed-on: https://go-review.googlesource.com/c/go/+/491175 Reviewed-by: Joseph Tsai <joetsai@digital-static.net> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com>
* cmd/go/internal/modfetch/codehost: initialize localGitURL lazily and clean ↵Bryan C. Mills2023-05-041-45/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | up skips Previously localGitURL was initialized in TestMain, which creates needless work if the test flags do not result in running a test that requires localGitURL. We had also been skipping a bunch of tests that used vcs-test.golang.org in order to avoid network traffic, but now that that content is served through an in-process vcweb server that is no longer necessary. (All of the 'git' tests together take less than a second to run.) The 'hg' tests are much slower, so we do still skip those in short mode. Updates #59940. Change-Id: Ie4f2d2bc825d7a011e25e754edf1a7c3c6010c77 Reviewed-on: https://go-review.googlesource.com/c/go/+/491659 Reviewed-by: Michael Matloob <matloob@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com>
* cmd/go: remove a redundant HasExec check in TestScript/READMEBryan C. Mills2023-05-041-4/+0
| | | | | | | | | | | | The test checks testenv.HasExec right before calling testenv.Command, but testenv.Command already skips the test if HasExec is false. Change-Id: I04716bf823a1b76640394a964973ff34c65afb1f Reviewed-on: https://go-review.googlesource.com/c/go/+/491658 Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org>
* cmd/go/internal/script: log the stop message instead of the state when stoppingBryan C. Mills2023-05-021-1/+1
| | | | | | | | | Change-Id: I3c887b5f3716e78dfffad6869f986c4381fae3e7 Reviewed-on: https://go-review.googlesource.com/c/go/+/488235 Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Michael Matloob <matloob@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/cgo: reject attempts to declare methods on C typesAlan Donovan2023-05-021-0/+31
| | | | | | | | | | | | | | | | | | | | | | | This change causes cgo to emit an error (with the same message as the compiler) when it encounters a declaration of a method whose receiver type is C.T or *C.T. Conceptually, C is another package, but unfortunately the desugaring of C.T is a type within the same package, causing the previous behavior to accept invalid input. It is likely that at least some users are intentionally exploiting this behavior, so this may break their build. We should mention it in the release notes. Fixes #57926 Change-Id: I513cffb7e13bc93d08a07b7e61301ac1762fd42d Reviewed-on: https://go-review.googlesource.com/c/go/+/490819 Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
* net: rewrite and simplify resolver configurationIan Lance Taylor2023-04-271-1/+4
| | | | | | | | | | | | | | | | | The resulting code behaves mostly the same. There are some minor differences in error cases when the cgo resolver is not available: instead of just falling back we keep trying to work out the right nsswitch.conf order. Change-Id: I17fadc940528fa2397043ac8f8ed7da3bd7a95c0 Reviewed-on: https://go-review.googlesource.com/c/go/+/487196 Reviewed-by: Damien Neil <dneil@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Mateusz Poliwczak <mpoliwczak34@gmail.com>
* cmd/go: skip the 'git' part of get_insecure_redirect in short modeBryan C. Mills2023-04-271-0/+2
| | | | | | | | | | | | | | | Invoking 'git' adds about 200ms to this test on a fast machine, probably more on a slow one. (As a general habit we skip the 'git' tests uniformly in short mode.) For #52545. Change-Id: Iea6d86a8c9c8b0f1fe51888faf7f5fe7dd8f1eb3 Reviewed-on: https://go-review.googlesource.com/c/go/+/488236 Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Than McIntosh <thanm@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/go: simplify code that still assumed the build cache could be nilBrad Fitzpatrick2023-04-263-64/+38
| | | | | | | | | | | | | | | | cache.Default always returns a non-nil value since Go 1.12; the docs were updated in https://go.dev/cl/465555. This updates all the callers of cache.Default that were checking whether the result was nil so the code isn't misleading/confusing to readers. Change-Id: Ia63567dd70affef6041c744259f65cea79a2752e Reviewed-on: https://go-review.googlesource.com/c/go/+/489355 Auto-Submit: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
* cmd/go: declare net hosts in script testsBryan C. Mills2023-04-2473-94/+112
| | | | | | | | | | | | | | | | | | | | | | | | | | Although we aren't precise about enforcing the hosts just yet, we can eventually use the declared hostnames to selectively skip tests (for example, if an external service has an outage while a Go release is being tested). Also relax the constraint to [short] in tests that require only vcs-test.golang.org, which has redirected to an in-process server since around CL 427914. Also enforce that tests that use the network actually use the [net] constraint, by setting TESTGONETWORK=panic in the test environment until the condition is evaluated. For #52545. For #54503. Updates #27494. Change-Id: I13be6b42a9beee97657eb45424882e787ac164c3 Reviewed-on: https://go-review.googlesource.com/c/go/+/473276 Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Bypass: Bryan Mills <bcmills@google.com> Reviewed-by: Russ Cox <rsc@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com>
* cmd/go: assert on more of the version string in TestScript/gotoolchainBryan C. Mills2023-04-211-1/+2
| | | | | | | | | | | | | | | The previous assert triggers whenever the 40-character git commit contains the substring "999", which happens with a probability decidedly greater than zero. For #57001. Change-Id: If0f1bc1a3dd0e6b7e66768d0cf3a79545ee4e5ed Reviewed-on: https://go-review.googlesource.com/c/go/+/486399 Reviewed-by: Michael Pratt <mpratt@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/go/internal/vcweb: replace ioutil with os and ioOleksandr Redko2023-04-212-4/+3
| | | | | | | | | | | Change-Id: I251788cbbb6d740ef24e7561cc4bee880b7bdff8 Reviewed-on: https://go-review.googlesource.com/c/go/+/485017 Reviewed-by: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Pratt <mpratt@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/dist: refactor generated cgo-support logicBryan C. Mills2023-04-206-4/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | During bootstrapping, cmd/dist writes a file indicating which GOOS/GOARCH combinations are valid, and which support cgo-enabled builds. That information previously went into the go/build package, but today it fits in more naturally in the internal/platform package (which already has a number of functions indicating feature support for GOOS/GOARCH combinations). Moreover, as of CL 450739 the cmd/go logic for determining whether to use cgo is somewhat more nuanced than the go/build logic: cmd/go checks for the presence of a C compiler, whereas go/build does not (mostly because it determines its configuration at package-init time, and checking $PATH for a C compiler is somewhat expensive). To simplify this situation, this change: - consolidates the “cgo supported” check in internal/platform (alongside many other platform-support checks) instead of making it a one-off in go/build, - and updates a couple of tests to use testenv.HasCGO instead of build.Default.CgoEnabled to decide whether to test a cgo-specific behavior. For #58884. For #59500. Change-Id: I0bb2502dba4545a3d98c9e915727382ce536a0f3 Reviewed-on: https://go-review.googlesource.com/c/go/+/483695 Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com>
* cmd/go: skip over all workspace modules in go mod verifyMichael Matloob2023-04-183-2/+39
| | | | | | | | | | | | | | | | | This was a remaining place where we made the assumption that there is only one workspace module. So we'd only skip the first workspace module when running go mod verify. Instead skip over the first MainModules.Len() modules of the buildlist, which are all the main modules. Fixes #54372 Change-Id: Ife687c907ae4326759c43cc35f78d429d5113b19 Reviewed-on: https://go-review.googlesource.com/c/go/+/485475 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org> Run-TryBot: Michael Matloob <matloob@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
* cmd/go: include internal/godebugs in TestNewReleaseRebuildsStalePackagesInGOPATHBryan C. Mills2023-04-181-0/+1
| | | | | | | | | | | | | | | This fixes a lingering failure on the 'longtest' builders, introduced in CL 476280. For #57001. Change-Id: I18872b1bc990dd16c0b86ebc5878c0a04ce9b2d9 Reviewed-on: https://go-review.googlesource.com/c/go/+/485897 Run-TryBot: Bryan Mills <bcmills@google.com> Commit-Queue: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Michael Matloob <matloob@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/go: mark gocacheverify godebug as undocumentedMichael Matloob2023-04-181-1/+1
| | | | | | | | | | | | | This avoids the panic for godebugs without documentation. Perhaps we eventually want to remove this godebug. Change-Id: I032cdded0f3ccf6681821286e2cb6f0b90a318c3 Reviewed-on: https://go-review.googlesource.com/c/go/+/485756 Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Bypass: Michael Matloob <matloob@golang.org> Run-TryBot: Michael Matloob <matloob@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org>
* cmd/go: stub out gotoolchain.go for wasip1 os build tagMichael Matloob2023-04-182-2/+2
| | | | | | | | | | | | | | There's a stub for gotoolchain.go for the js build tag because js/wasm doesn't define syscall.Exec. But there are builders that are wasm but not js, which also don't have syscall.Exec. The wasip1 GOOS is one example. Stub out gotoolchain.go for wasip1 also. Change-Id: I224bb385474ad9c5d3c28a83a000f450dfb43c0d Reviewed-on: https://go-review.googlesource.com/c/go/+/485735 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Michael Matloob <matloob@golang.org> Run-TryBot: Michael Matloob <matloob@golang.org>
* cmd/go: add check for unknown godebug settingRuss Cox2023-04-185-18/+25
| | | | | | | | | | | | A //go:debug line mentioning an unknown or retired setting should be diagnosed as making the program invalid. Do that. We agreed on this in the proposal but I forgot to implement it. Change-Id: Ie69072a1682d4eeb6866c02adbbb426f608567c4 Reviewed-on: https://go-review.googlesource.com/c/go/+/476280 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/go: change toolchain based on $GOTOOLCHAINRuss Cox2023-04-1851-39/+946
| | | | | | | | | | | | | | | | | | | For proposal #57001, add code to reinvoke a different Go toolchain based on $GOTOOLCHAIN. The toolchain is searched for in $PATH first and otherwise downloaded. The download is a standard module download, so the toolchain is validated using the checksum database before being executed or even stored in the file system. Followup CLs will refine the exact toolchain selection and implement other parts of the proposal. This is only the download+reinvoke code. For #57001. Change-Id: I44363cbd916dac01342b1bfce6a487fe7166be4a Reviewed-on: https://go-review.googlesource.com/c/go/+/475955 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org>
* cmd/go/internal/cache: update docs on cache accessor funcBrad Fitzpatrick2023-04-171-1/+2
| | | | | | | | | | | Its docs went stale in Go 1.12 when the build cache became required. Signed-off-by: Brad Fitzpatrick <bradfitz@golang.org> Change-Id: Icb7b06dc5147a858f00460e7cfe85b79b6b6f0eb Reviewed-on: https://go-review.googlesource.com/c/go/+/465555 Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* path/filepath,cmd/go: skip tests involving double-symlinks on iosBryan C. Mills2023-04-141-0/+1
| | | | | | | | | | | For #59586. Change-Id: I092f7a4abce1074b8eef64a3ecf9fc187914709b Reviewed-on: https://go-review.googlesource.com/c/go/+/484755 Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: David Chase <drchase@google.com> TryBot-Bypass: Bryan Mills <bcmills@google.com>
* cmd/go: make go line declare minimum required Go versionRuss Cox2023-04-142-96/+10
| | | | | | | | | | | | | | | | | | For #57001, enforce the go line as declaring the minimum required version of Go that can compile a module. Modules that maintain compatibility with old versions of Go but want to make use of new features in //go:build-constrained files will be able to do so: the //go:build constraint will be interpreted as changing the minimum Go version for that file and will unlock the Go features allowed in that version. Change-Id: Ibeeb7c93ce7ea2e5187d78af0757cbfac19484a0 Reviewed-on: https://go-review.googlesource.com/c/go/+/476279 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Russ Cox <rsc@golang.org> Auto-Submit: Russ Cox <rsc@golang.org>
* cmd/go: parallelize part of loading test packages in listMichael Matloob2023-04-132-107/+148
| | | | | | | | | | | | | | | | load.TestPackagesAndErrors is given an optional done func() argument. If set, load.TestPackagesAndErrors will perform part of its work asynchronously and call done when done. This allows go list to run testPackagesAndErrors so that the parallelizable parts of TestPackagesAndErrors run in parallel, making go list -e faster. Fixes #59157 Change-Id: I11f45bbb3ea4ceda928983bcf9fd41bfdcc4fbd9 Reviewed-on: https://go-review.googlesource.com/c/go/+/484496 Run-TryBot: Michael Matloob <matloob@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
* cmd/go: skip TestScript/list_goroot_symlink on darwinBryan C. Mills2023-04-131-0/+1
| | | | | | | | | | | | | | | | | | The list_goroot_symlink test relies on fsys.Walk (and ultimately syscall.Lstat) conforming to POSIX pathname resolution semantics. POSIX requires that symlinks ending in a slash be fully resolved, but it appears that lstat in current darwin kernels does not fully resolve the last pathname component when it is a symlink to a symlink. For #59586. For #35678. Change-Id: I37526f012ba94fa1796b33109a41c3226c967d3e Reviewed-on: https://go-review.googlesource.com/c/go/+/484216 Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Bypass: Bryan Mills <bcmills@google.com>
* cmd/compile: fix reproducible build of aliased generic typesMatthew Dempsky2023-04-121-0/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Due to a missing "&& !alias" check, the unified linker was treating type aliases the same as defined types for the purpose of exporting method bodies. The methods will get exported anyway alongside the aliased type, so this mistake is normally harmless. However, if multiple type aliases instantiated the same generic type but with different type arguments, this could result in the same (generic) method body being exported multiple times under different symbol names. Further, because bodies aren't expected to be exported multiple times, we were sorting them simply based on index. And consequently, the sort wasn't total and is sensitive to the map iteration order used while ranging over linker.bodies. The fix is simply to add the missing "&& !alias" check, so that we don't end up with duplicate bodies in the first place. Thanks rsc@ for providing a minimal repro case. Fixes #59571. Change-Id: Iaa55968cc7110b601e2f0f9b620901c2d55f7014 Reviewed-on: https://go-review.googlesource.com/c/go/+/484155 Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
* cmd/go: rewrite collectDeps to only depend on imports' depsMichael Matloob2023-04-112-35/+126
| | | | | | | | | Change-Id: I0cac9f32855e49e9899709a2f4421083aa0e75cc Reviewed-on: https://go-review.googlesource.com/c/go/+/483515 Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Michael Matloob <matloob@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org>
* cmd/go/internal/cache: return and check errors from TrimBryan C. Mills2023-04-113-15/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's fine to ignore errors when reading trim.txt, since it might not exist or might be corrupted. However, if we encounter an error in writing the file, we will end up trimming again at every cmd/go invocation, which will cause invocations to become progressively slower (because each command will check more and more cache files for trimming). Although that situation would not cause the output of any 'go' command to be invalid, it still seems better to escalate the problem to the user to be fixed instead of proceeding in a degraded state. Returning an explicit error also allows TestCacheTrim to skip if the Trim error indicates that a required operation (in this case, file locking) is not supported by the platform or filesystem. For #58141. Updates #35220. Updates #26794. Change-Id: Iedb94bff4544fd9914f5ac779a783a116372c80f Reviewed-on: https://go-review.googlesource.com/c/go/+/482795 Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Auto-Submit: Bryan Mills <bcmills@google.com>
* cmd/go: localize computation of deps/depserrors in listMichael Matloob2023-04-103-107/+104
| | | | | | | | | | | | | | | | Stop depending on DepsErrors to report errors to the user and instead only use it and compute it in list. Instead, use Incomplete to figure out when a package or its depencies have an error, and only if they do, do the work of finding all those errors. For #59157 Change-Id: Ied927f53e7b1f66fad9248b40dd11ed960b3ef91 Reviewed-on: https://go-review.googlesource.com/c/go/+/483495 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Michael Matloob <matloob@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Michael Matloob <matloob@golang.org>
* cmd/go: return and handle errors from loadImport for bad importsMichael Matloob2023-04-105-67/+133
| | | | | | | | | | | | | | | | | | And assign the error to the importing package. Before this change, for some errors for bad imports, such as importing a vendored package with the wrong path, we would make a dummy package for the imported package with the error on it. Instead report the error on the importing package where it belongs. Do so by returning an error from loadImport and handling it on the importing package. For #59157 Change-Id: I952e1a82af3857efc5da4fd3f8bc6be473a60cf5 Reviewed-on: https://go-review.googlesource.com/c/go/+/482877 Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Michael Matloob <matloob@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd: add wasip1 supportJohan Brandhorst-Satzkorn2023-04-067-17/+21
| | | | | | | | | | | | | | | | For #58141 Co-authored-by: Richard Musiol <neelance@gmail.com> Co-authored-by: Achille Roussel <achille.roussel@gmail.com> Co-authored-by: Julien Fabre <ju.pryz@gmail.com> Co-authored-by: Evan Phoenix <evan@phx.io> Change-Id: I530ea78a3cd142f3a745f650b21c30e7f10ce981 Reviewed-on: https://go-review.googlesource.com/c/go/+/479621 Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
* cmd/go: improve packages help descriptionOleksandr Redko2023-04-062-2/+2
| | | | | | | | | | | | Clarify that 'action' is not the valid 'go' command. Change-Id: I0a77722c46a3dc56f81c5e6e177e0c73bc60adc2 Reviewed-on: https://go-review.googlesource.com/c/go/+/482455 Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>