Skip to content

Commit 961837d

Browse files
author
Bryan C. Mills
committed
Revert "cmd/go: add a Latest field to the output of 'go mod download -json'"
This reverts CL 183841. Fixes #34533 Reason for revert: Introduced a significant performance regression for repos with many incompatible-version tags. Change-Id: I75d7fd76e6e1a0902b114b00167b38439e0f8221 Reviewed-on: https://go-review.googlesource.com/c/go/+/198699 Run-TryBot: Bryan C. Mills <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Katie Hockman <[email protected]> Reviewed-by: Jay Conrod <[email protected]>
1 parent 0471417 commit 961837d

File tree

5 files changed

+1
-74
lines changed

5 files changed

+1
-74
lines changed

src/cmd/go/alldocs.go

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cmd/go/internal/modcmd/download.go

-30
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ corresponding to this Go struct:
4343
Dir string // absolute path to cached source root directory
4444
Sum string // checksum for path, version (as in go.sum)
4545
GoModSum string // checksum for go.mod (as in go.sum)
46-
Latest bool // would @latest resolve to this version?
4746
}
4847
4948
See 'go help modules' for more about module queries.
@@ -66,7 +65,6 @@ type moduleJSON struct {
6665
Dir string `json:",omitempty"`
6766
Sum string `json:",omitempty"`
6867
GoModSum string `json:",omitempty"`
69-
Latest bool `json:",omitempty"`
7068
}
7169

7270
func runDownload(cmd *base.Command, args []string) {
@@ -105,31 +103,6 @@ func runDownload(cmd *base.Command, args []string) {
105103
work.Add(m)
106104
}
107105

108-
latest := map[string]string{} // path → version
109-
if *downloadJSON {
110-
// We need to populate the Latest field, but if the main module depends on a
111-
// version newer than latest — or if the version requested on the command
112-
// line is itself newer than latest — that's not trivial to determine from
113-
// the info returned by ListModules. Instead, we issue a separate
114-
// ListModules request for "latest", which should be inexpensive relative to
115-
// downloading the modules.
116-
var latestArgs []string
117-
for _, m := range mods {
118-
if m.Error != "" {
119-
continue
120-
}
121-
latestArgs = append(latestArgs, m.Path+"@latest")
122-
}
123-
124-
if len(latestArgs) > 0 {
125-
for _, info := range modload.ListModules(latestArgs, listU, listVersions) {
126-
if info.Version != "" {
127-
latest[info.Path] = info.Version
128-
}
129-
}
130-
}
131-
}
132-
133106
work.Do(10, func(item interface{}) {
134107
m := item.(*moduleJSON)
135108
var err error
@@ -160,9 +133,6 @@ func runDownload(cmd *base.Command, args []string) {
160133
m.Error = err.Error()
161134
return
162135
}
163-
if latest[m.Path] == m.Version {
164-
m.Latest = true
165-
}
166136
})
167137

168138
if *downloadJSON {

src/cmd/go/testdata/script/mod_download.txt

+1-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ stderr 'this.domain.is.invalid'
1717
stdout '"Error": ".*this.domain.is.invalid.*"'
1818

1919
# download -json with version should print JSON
20-
# and download the .info file for the 'latest' version.
2120
go mod download -json 'rsc.io/quote@<=v1.5.0'
2221
stdout '^\t"Path": "rsc.io/quote"'
2322
stdout '^\t"Version": "v1.5.0"'
@@ -28,14 +27,13 @@ stdout '^\t"Sum": "h1:6fJa6E\+wGadANKkUMlZ0DhXFpoKlslOQDCo259XtdIE="' # hash of
2827
stdout '^\t"GoModSum": "h1:LzX7hefJvL54yjefDEDHNONDjII0t9xZLPXsUe\+TKr0="'
2928
! stdout '"Error"'
3029

31-
exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.info
32-
3330
# download queries above should not have added to go.mod.
3431
go list -m all
3532
! stdout rsc.io
3633

3734
# add to go.mod so we can test non-query downloads
3835
go mod edit -require rsc.io/[email protected]
36+
! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.info
3937
! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.mod
4038
! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.zip
4139

src/cmd/go/testdata/script/mod_download_latest.txt

-20
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,8 @@
11
env GO111MODULE=on
22

3-
# If the current version is not latest, 'go list -u' should include its upgrade.
43
go list -m -u all
54
stdout 'rsc.io/quote v1.2.0 \[v1\.5\.2\]'
65

7-
# If the current version is latest, 'go list -u' should omit the upgrade.
8-
go get -d rsc.io/[email protected]
9-
go list -m -u all
10-
stdout 'rsc.io/quote v1.5.2$'
11-
12-
# If the current version is newer than latest, 'go list -u' should
13-
# omit the upgrade.
14-
go get -d rsc.io/[email protected]
15-
go list -m -u all
16-
stdout 'rsc.io/quote v1.5.3-pre1$'
17-
18-
# If the current build list has a higher version and the user asks about
19-
# a lower one, -u should report the upgrade for the lower one
20-
# but leave the build list unchanged.
21-
go list -m -u rsc.io/[email protected]
22-
stdout 'rsc.io/quote v1.5.1 \[v1.5.2\]$'
23-
go list -m -u rsc.io/quote
24-
stdout 'rsc.io/quote v1.5.3-pre1$'
25-
266
-- go.mod --
277
module x
288
require rsc.io/quote v1.2.0

0 commit comments

Comments
 (0)