golang/go

cmd/go: 'go list -m' wildcards don't work with version queries

开放

#45,485 创建于 2021年4月10日

 (4 条评论) (0 个反应) (0 位负责人)Go (19,008 个派生)batch import
GoCommandNeedsInvestigationhelp wantedmodules

仓库指标

星标
 (133,883 个星标)
PR 合并指标
 (30 天内没有已合并 PR)

描述

go get supports ... wildcards, and supports version queries such as @latest, and allows the user to combine the two in the obvious way.

go list -m supports ... wildcards, and supports version queries such as @latest. However, it errors out when both are used in the same argument. It should not — it should instead interpret those queries analogous to how go get does.

$ go version
go version devel go1.17-a7e16abb2 Thu Apr 8 07:33:58 2021 +0000 linux/amd64

$ go mod init example.com
go: creating new go.mod: module example.com

$ go get -d golang.org/x/tools/...@latest
go: downloading golang.org/x/tools v0.1.0
go: downloading golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4
go: downloading golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
go: downloading golang.org/x/net v0.0.0-20201021035429-f5854403a974
go: downloading golang.org/x/mod v0.3.0
go: downloading golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9
go: downloading github.com/yuin/goldmark v1.2.1
go get: added golang.org/x/tools v0.1.0

$ go list -m golang.org/x/tools/...
golang.org/x/tools v0.1.0

$ go list -m golang.org/x/tools@latest
golang.org/x/tools v0.1.0

$ go list -m golang.org/x/tools/...@latest
go list -m: golang.org/x/tools/...@latest: malformed module path "golang.org/x/tools/...": invalid path element "..."

$

I noticed this while updating go list for #36460.

CC @jayconrod @matloob

贡献者指南