Description
#40276 allows using go install path@version
to install a package at a specific version, ignoring the current module.
#42088 is an accepted proposal to allow go run path@version
with similar semantics - run a main package at a specific version, ignoring the current module.
While I agree that these semantics are most often useful for go install
and go run
, I argue that they would also be useful for other cmd/go commands. In this proposal, I want to make a case for go list path@version
.
The main use case I want to bring forth is to list the packages included in a specific version of a module. Right now, I can only accomplish this via:
go mod init tmp
go get -d ${module}@${version}
go list ${module}/...
rm go.mod go.sum
It could instead be just go list ${module}/...@${version}
.
For reference, I'm using this to generate static HTML pages to serve go get
and browser requests for vanity import paths; see https://github.com/mvdan/mvdan.cc/blob/572593964513b20649c474cc9a6559405ec9cc29/gen-go-modules.bash#L49-L53.
I think this feature would also make go list
a bit more consistent, since go list -m path@version
currently works just fine.