Skip to content

Commit

Permalink
cmd/golangorg: return all known Go toolchain versions
Browse files Browse the repository at this point in the history
Update https://go.dev/dl/mod/golang.org/toolchain/@v/list to list
all known toolchain versions. This previously only listed the
stable versions.

Returning only the stable versions of go was inconsistent with
proxy.golang.org, leading to a different experience when running the
go command with GOPROXY=direct. This prevented the go command from
identifying newer versions of the toolchain that have been released.

Fixes golang/go#61359

Change-Id: I09729cc4826e40e5d5ee1effff6ed476ff983595
Reviewed-on: https://go-review.googlesource.com/c/website/+/551595
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
  • Loading branch information
suzmue committed Jan 2, 2024
1 parent 95f774f commit 813bd0c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
5 changes: 5 additions & 0 deletions cmd/golangorg/testdata/web.txt
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,11 @@ body ~ (?m)^v0\.0\.1-go1\.\d+\.\d+.darwin-arm64$
body ~ (?m)^v0\.0\.1-go1\.\d+\.\d+.darwin-amd64$
body ~ (?m)^v0\.0\.1-go1\.\d+\.\d+.linux-386$
body ~ (?m)^v0\.0\.1-go1\.\d+\.\d+.windows-amd64$
body ~ (?m)^v0\.0\.1-go1\.\d+rc\d+\.darwin-arm64$
body ~ (?m)^v0\.0\.1-go1\.\d+rc\d+\.darwin-amd64$
body ~ (?m)^v0\.0\.1-go1\.\d+rc\d+\.linux-386$
body ~ (?m)^v0\.0\.1-go1\.\d+rc\d+\.windows-amd64$
body !contains bootstrap

GET https://go.dev/ref
redirect == /doc/#references
Expand Down
33 changes: 17 additions & 16 deletions internal/dl/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ func (h server) listHandler(w http.ResponseWriter, r *http.Request) {
}

// toolchainList serves the toolchain module version list.
// We only list the stable releases, even though older releases are available as well.
func (h server) toolchainList(w http.ResponseWriter, r *http.Request) {
d, err := h.listData(r.Context())
if err != nil {
Expand All @@ -91,22 +90,24 @@ func (h server) toolchainList(w http.ResponseWriter, r *http.Request) {
}

var buf bytes.Buffer
for _, r := range d.Stable {
for _, f := range r.Files {
if f.Kind != "archive" {
continue
for _, l := range [][]Release{d.Stable, d.Unstable, d.Archive} {
for _, r := range l {
for _, f := range r.Files {
if f.Kind != "archive" || f.Arch == "bootstrap" {
continue
}
buf.WriteString("v0.0.1-")
buf.WriteString(f.Version)
buf.WriteString(".")
buf.WriteString(f.OS)
buf.WriteString("-")
arch := f.Arch
if arch == "armv6l" {
arch = "arm"
}
buf.WriteString(arch)
buf.WriteString("\n")
}
buf.WriteString("v0.0.1-")
buf.WriteString(f.Version)
buf.WriteString(".")
buf.WriteString(f.OS)
buf.WriteString("-")
arch := f.Arch
if arch == "armv6l" {
arch = "arm"
}
buf.WriteString(arch)
buf.WriteString("\n")
}
}
w.Write(buf.Bytes())
Expand Down

0 comments on commit 813bd0c

Please sign in to comment.