Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proposal: cmd/go: enhance go version to check if running latest revision of Go #59523

Open
mohamedattahri opened this issue Apr 10, 2023 · 6 comments
Milestone

Comments

@mohamedattahri
Copy link

The Go ecosystem lacks a standard way to check whether a system is running the latest revision of the current {major}.{minor} version of Go available.

https://go.dev/dl/?mode=json already provides a machine-readable (JSON) list of all the currently supported versions, but integrating it into a toolchain often requires complex scripts with external dependencies (e.g. curl, jq).

It seems like something the go command should handle in a consistent way.

My proposal is to extend go version with a new check command as following:

With no parameters, it would check whether the system is running the latest revision of the current major version installed.

> go version check
Running the latest revision of Go 1.20 (go1.20.3 darwin/arm64).
(code 0)

With a --latest flag, it would check whether the system is running the latest major release of Go.

> go version check --latest
Go 1.20 is available → https://tip.golang.org/doc/go1.20
(code 1)

Ideally, this would also serve warnings for out-of-support versions:

> go version check
Go 1.18 is no longer supported (go1.18.10 darwin/arm64).
(code 1)
@gopherbot gopherbot added this to the Proposal milestone Apr 10, 2023
@thediveo
Copy link
Contributor

doesn't this break lots of existing scripts, etc.?

@mvdan
Copy link
Member

mvdan commented Apr 10, 2023

Also see #57001.

@mohamedattahri
Copy link
Author

@thediveo It would scripts calling go version against a binary named check, but there are workarounds for that (go check?). Not really opinionated about the syntax.

@mvdan Thanks, helpful context. I'd personally be opposed to making go version install anything on my system.

@ianlancetaylor
Copy link
Member

CC @bcmills @matloob

@mohamedattahri
Copy link
Author

FYI - Sharing some code I'm using today, and which could be adapted. https://gist.github.com/mohamedattahri/8cacc47b710eb3e2b170eef59bcd4a5b

@na4ma4
Copy link

na4ma4 commented Feb 19, 2025

I would think it would work better having something like:

$ go version --check tip
go1.24.0
(Exit Code: 1)
$ go version --check '>=1.20'
go1.24.0
(Exit Code: 0)
$ go version --check '<=1.21'
go1.24.0
(Exit Code: 1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Incoming
Development

No branches or pull requests

6 participants