Description
Hi,
I was testing vgo the other day, trying to import some 3rd party dependencies that have version v2.0 or higher released on Github, but I couldn't figure out how.
Example:
Given github.com/go-chi/chi has latest version v3.3.2 released as a git tag on Github,
I'd like to import github.com/go-chi/chi/v3
in my project, develop against it and eventually vendor it via vgo vendor
.
package main
import "github.com/go-chi/chi/v3"
func main() {
_ = chi.NewRouter()
}
But since github.com/go-chi/chi didn't release a v3 module yet, I get this error:
$ vgo run main.go
vgo: creating new go.mod: module github.com/VojtechVitek/vgo-test
vgo: resolving import "github.com/go-chi/chi/v3"
vgo: finding github.com/go-chi/chi (latest)
vgo: adding github.com/go-chi/chi v1.0.0
vgo: import "github.com/go-chi/chi/v3" [/Users/vojtechvitek/go/src/v/github.com/go-chi/[email protected]/v3]: open /Users/vojtechvitek/go/src/v/github.com/go-chi/[email protected]/v3: no such file or directory
vgo found version v1.0.0 but couldn't find "v3" subpkg. So I added an explicit version to my go.mod file and tried again:
$ cat go.mod
module github.com/VojtechVitek/vgo-test
require (
github.com/go-chi/chi v3.3.2
)
running vgo again caused a silent side effect:
module github.com/VojtechVitek/vgo-test
require (
- github.com/go-chi/chi v3.3.2
+ github.com/go-chi/chi v0.0.0-20171222161133-e83ac2304db3
)
Hmm, seems like vgo doesn't see any v2.0+ tags? After reading some more blog posts on https://research.swtch.com (since vgo
CLI help didn't seem to be very helpful / novice user friendly), I confirmed with:
$ vgo list -t github.com/go-chi/chi
github.com/go-chi/chi
v0.9.0
v1.0.0
Now, I might be missing something, but it's not really clear to me how can I import v2.0+ or v3.0+ of a package (should I say module?) that I don't have any control over and "is not ready yet".
Are there any guidelines for package consumers about this? Are there any guidelines for package authors? I couldn't find anything useful neither in research.swtch.com/vgo-module, nor in the accepted proposal or in the wiki.
// EDIT:
$ 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
Ahaa, so I can list v3.0+ tags. But how do I use them in my monorepo properly?
$ vgo get github.com/go-chi/chi/v3
vgo: creating new go.mod: module github.com/VojtechVitek/vgo-test
vgo: github.com/go-chi/chi/v3 v3.3.2: missing or invalid go.mod
vgo get: missing or invalid go.mod