golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
123.73k stars 17.63k forks source link

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

Open bcmills opened 3 years ago

bcmills commented 3 years ago

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

anton-kuklin commented 3 years ago

Hi @bcmills, I'll work on it.

jamdagni86 commented 3 years ago

hey @justplesh would it be OK if I can send a pull request for this? I am almost done with the fix.

anton-kuklin commented 3 years ago

@jamdagni86 sure, if you have already done it - it's great.

gopherbot commented 3 years ago

Change https://golang.org/cl/312950 mentions this issue: cmd/go: add support for wildcards in 'go list -m'