Skip to content

proposal: x/website: have endpoint to query for the latest bugfix version #36898

Closed
@mvdan

Description

@mvdan

Background

#34864 covers documenting the endpoint better. Right now, it's documented at https://godoc.org/golang.org/x/website/internal/dl. Listing the versions is very useful, so that endpoint is great.

However, there is one common operation that's not covered by the endpoint: showing the latest Go patch release for a major version like 1.12 or 1.13. This is useful to quickly download and install such a latest version, or to use it for a line like docker run golang:$(<query> 1.13.x) ..., and so on.

CI systems like Travis or GitHub Actions allow you to specify 1.13.x as a Go version in their configs. Internally, they query /dl?mode=json, and figure out what the latest version is. That's fine, because that software is pretty complex anyway, so a bit of JSON parsing is not terrible.

However, this gets harder when one is writing shell script one-liners, or portable scripts in general. There's just no way to do it in POSIX Shell or even Bash, let alone shells for other systems.

/VERSION?m=text almost satisfies this purpose, but it only shows the latest single release (not 1.12.x, 1.11.x, etc), and it sometimes lags behind even days after a newer release has gone out.

Proposed solution

Given that /VERSION is a static file and not an endpoint, I'm going to suggest that we extend the existing /dl endpoint instead. But this choice can be changed.

We don't want the result to be JSON, for the reasons laid out before. So the first step is adding ?mode=text alongside ?mode=json. Similar to /VERSION?m=text, it simply prints one version name per line, and nothing else. This is already useful by itself; one could figure out the absolute latest version via curl .../dl?mode=text | sed 1q, for example.

To support querying for the latest bugfix version for a particular "major" release like 1.12, we'd add another parameter latest: /dl?mode=text&latest=1.12.x. Given a string ${version}.x, it returns the latest bugfix release for that version. The version must be in the format ${number}.{number}, and the suffix .x must be present, to avoid ambiguity with 1.12 (actually 1.12.0).

Queries like /dl?mode=json&latest=1.12.x should also work, doing what you'd imagine. Instead of returning one line with just the version name, you'd get a JSON element with the structured data for the release in question.

/cc @dmitshur @myitcv @andybons

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions