cmd/golangorg: return all known Go toolchain versions

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>
This commit is contained in:
Suzy Mueller 2023-12-19 15:40:20 -08:00
Родитель 95f774fca5
Коммит 813bd0c33a
2 изменённых файлов: 22 добавлений и 16 удалений

5
cmd/golangorg/testdata/web.txt поставляемый
Просмотреть файл

@ -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

Просмотреть файл

@ -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 {
@ -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())