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

cmd/go: list -m -versions omits mismatched major versions #25656

Closed
fransoaardi opened this issue May 31, 2018 · 12 comments
Closed

cmd/go: list -m -versions omits mismatched major versions #25656

fransoaardi opened this issue May 31, 2018 · 12 comments

Comments

@fransoaardi
Copy link

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.10.2 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

  • replaced home directory as ${home}

GOARCH="amd64"
GOBIN=""
GOCACHE="${home} /Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="${home}/go"
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/x6/pxwr89_95yxbhw5nh8b7jk1w0000gn/T/go-build318943644=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

image

just typed

vgo list -t github.com/go-chi/chi 

to get available releases but got only these two versions.
Actually, go-chi/chi has latest release of v3.3.2

image

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.

What did you expect to see?

getting whole lists of available release

What did you see instead?

just a part of available release

@gopherbot gopherbot added this to the vgo milestone May 31, 2018
@fransoaardi fransoaardi changed the title x/vgo can't get whole release list with vgo list -t command x/vgo: can't get whole release list with vgo list -t command May 31, 2018
@myitcv
Copy link
Member

myitcv commented Jun 1, 2018

I'll reference an answer I gave in #25674 (comment)

There are a couple of things at play here:

  1. at the time of writing, github.com/go-chi/chi has not been converted to be a Go module
  2. it has a major version >= 2

As a result therefore, what you are attempting won't, to my understanding, work until point 1 has been addressed.

In the meantime you will need to explicitly vgo get github.com/go-chi/chi@v3.3.2 (or similar) (see linked comment)

@fransoaardi
Copy link
Author

@myitcv
Thanks for ur answer.

In short, according to ur answer, the solution would be

1) to get the 3.3.2 version,  I need to explicitly write the version I want. 
2) go-chi/chi pkg generates go.mod

I wish I can get whole versions without go.mod pkg someday.
Thanks.

@myitcv
Copy link
Member

myitcv commented Jun 1, 2018

Here's a fully working example that uses v3.3.2.

Start by getting vgo in the usual way:

$ go get -u golang.org/x/vgo

Create a module using the github.com/go-chi/chi example:

$ mkdir hello
$ cd hello
$ cat <<EOD >hello.go
package main // import "example.com/hello"

import (
        "net/http"
        "github.com/go-chi/chi"
)

func main() {
        r := chi.NewRouter()
        r.Get("/", func(w http.ResponseWriter, r *http.Request) {
                w.Write([]byte("welcome"))
        })
        http.ListenAndServe(":3000", r)
}
EOD

Mark this as a module by creating a go.mod:

$ echo >go.mod

Now because, at the time of writing, github.com/go-chi/chi:

  • has a major version >= 2
  • has not been converted to a Go (vgo) module
  • we want to use v3.3.2

we need to vgo get that specific version, which will be retrieved as a v0.0.0 psuedo version:

$ vgo get github.com/go-chi/chi@v3.3.2
vgo: finding github.com/go-chi/chi v0.0.0-20171222161133-e83ac2304db3
vgo: downloading github.com/go-chi/chi v0.0.0-20171222161133-e83ac2304db3

Now do a build to check all is good:

$ vgo build

And check the contents of go.mod:

$ cat go.mod
module example.com/hello

require github.com/go-chi/chi v0.0.0-20171222161133-e83ac2304db3

Version details for reference:

go version go1.10.2 linux/amd64 vgo:2018-02-20.1
vgo commit: 7c0cf33f39ccf5d8e4c59d34a150425ddac7df6a

@oiooj
Copy link
Member

oiooj commented Jun 1, 2018

@fransoaardi You can run: vgo list -t github.com/go-chi/chi/v3

github.com/go-chi/chi/v3
	v3.0.0
	v3.1.0
	v3.1.1
	v3.1.2
	v3.1.3
	v3.1.4
	v3.1.5
	v3.2.0
	v3.2.1
	v3.3.0
	v3.3.1
	v3.3.2

@myitcv
Copy link
Member

myitcv commented Jun 1, 2018

@oiooj you're quite right, thank you!

@myitcv
Copy link
Member

myitcv commented Jun 5, 2018

@oiooj @fransoaardi - for reference, I've also added #25712. As part of the description for that issue, I've asked whether we should perhaps have an issue that more broadly covers the requirements/etc for vgo list. One of the items in that list is giving vgo list -t (or some variant of it) the ability to pull back all versions across all major version numbers.

@rsc rsc changed the title x/vgo: can't get whole release list with vgo list -t command x/vgo: list -t omits mismatched major versions Jun 6, 2018
@rsc
Copy link
Contributor

rsc commented Jun 6, 2018

This is basically working as intended but unfortunate for older code that didn't know about the semantic import versioning conventions. Will need to think about whether to surface more here.

@bcl
Copy link

bcl commented Jun 11, 2018

I think this is related: If a project didn't tag a release using a full semver version it won't be listed:

vgo list -t github.com/gin-gonic/gin/
    v1.1.1
    v1.1.2
    v1.1.3
    v1.1.4

And if you try to get v1.2 it rewrites it as v1.2.0 and fails:

vgo get github.com/gin-gonic/gin@v1.2
vgo get github.com/gin-gonic/gin: unknown revision "v1.2.0"

This may be working as designed, but I find it somewhat unexpected. I've asked gin to add a v1.2.0 tag, but maybe vgo should handle it more gracefully?

@thinkerou
Copy link

The tag of gin usually is v1.x.x, but it have one release tag v1.2 now, so I think vgo also should handle it, like tag also hugo and gogs.

@myitcv
Copy link
Member

myitcv commented Jun 30, 2018

Just to point out that since https://go-review.googlesource.com/120198 vgo list -t is no longer an option. But I suspect that's a temporary state of affairs because this issue remains open and is the placeholder for some vgo list points (per #25712 (comment))

@rsc
Copy link
Contributor

rsc commented Jul 6, 2018

The new form is list -m -versions and it still omits the mismatched major versions.

@rsc rsc changed the title x/vgo: list -t omits mismatched major versions x/vgo: list -m -versions omits mismatched major versions Jul 6, 2018
@rsc rsc modified the milestones: vgo, Go1.11 Jul 12, 2018
@rsc rsc added the modules label Jul 12, 2018
@rsc rsc changed the title x/vgo: list -m -versions omits mismatched major versions cmd/go: list -m -versions omits mismatched major versions Jul 12, 2018
@rsc
Copy link
Contributor

rsc commented Jul 17, 2018

Mismatched major versions that are not using semantic import versioning (like in the example here) will be listed after the fix for #26238 lands, so closing this as a dup of #26238.

It's out of scope to list versions for other modules (foo/v2's versions when this is foo).

@rsc rsc closed this as completed Jul 17, 2018
@golang golang locked and limited conversation to collaborators Jul 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants