modules exclude version and above

514 views
Skip to first unread message

Jérôme LAFORGE

unread,
Jan 3, 2020, 3:49:27 PM1/3/20
to golang-nuts
Hello,

Does it exist a way to exclude modules' version and above  ?

Currently I have to do this (in order to not use v2) in my go.mod:

exclude (
    github.com/nicksnyder/go-i18n v2.0.1+incompatible
    github.com/nicksnyder/go-i18n v2.0.2+incompatible
    github.com/nicksnyder/go-i18n v2.0.3+incompatible
)

Many thx
Jérôme

Bryan C. Mills

unread,
Jan 6, 2020, 12:44:45 PM1/6/20
to golang-nuts
Could you provide explicit steps (ideally a `go.mod` file and a corresponding `.go` source file, and the version of the Go toolchain you are using) to reproduce the problem?

All three of those `v2` versions appear to have `go.mod` files, so the `go` command should not allow them to be used as `+incomptable` versions at all, let alone use them by default.

Moreover, because the latest `v1` release of that module includes a go.mod file, as of Go 1.14 beta 1 the `go` command should ignore `+incompatible` versions when resolving upgrades to that module.

Jérôme LAFORGE

unread,
Jan 6, 2020, 1:43:44 PM1/6/20
to golang-nuts
Thx for your support.

> Could you provide explicit steps (ideally a `go.mod` file and a corresponding `.go` source file, and the version of the Go toolchain you are using) to reproduce the problem?
With this go.mod https://play.golang.org/p/PeSbMFMAsHf & with go get -u ./... the version stills on v1 branch.

With this go.mod https://play.golang.org/p/jAw0ENF1Y6V (without exclude on all versions in v2 branch) & with go get -u ./... I got this error:
go: downloading github.com/nicksnyder/go-i18n v2.0.3+incompatible
go: extracting github.com/nicksnyder/go-i18n v2.0.3+incompatible
build xxx: cannot load github.com/nicksnyder/go-i18n/i18n: module github.com/nicksnyder/go-i18n@latest found (v2.0.3+incompatible), but does not contain package github.com/nicksnyder/go-i18n/i18n

And the go.mod has changed:
--- a/src/xxx/go.mod
+++ b/src/xxx/go.mod
@@ -27,7 +27,7 @@ require (
        github.com/nats-io/jwt v0.3.2 // indirect
        github.com/nats-io/nats-server/v2 v2.1.0 // indirect
        github.com/nats-io/nats.go v1.9.1
-       github.com/nicksnyder/go-i18n v1.10.1
+       github.com/nicksnyder/go-i18n v2.0.3+incompatible
        github.com/pelletier/go-toml v1.6.0 // indirect
        github.com/prometheus/client_golang v1.3.0
        github.com/rogpeppe/go-charset v0.0.0-20190617161244-0dc95cdf6f31


For the source files, I can't provide it.

Thx for the links, I will check it.

Jérôme LAFORGE

unread,
Jan 6, 2020, 1:52:40 PM1/6/20
to golang-nuts
I use this version:
go version go1.13.5 linux/amd64

Bryan C. Mills

unread,
Jan 7, 2020, 4:02:59 PM1/7/20
to Jérôme LAFORGE, golang-nuts
Ok, I think I've figured out what's going on.
The commits tagged `v2.0.2` and `v2.0.3` in this repo have a module in subdirectory `v2` that declares its path to be `github.com/nicksnyder/go-i18n/v2`.
However, that module cannot match the requested path `github.com/nicksnyder/go-i18n`, so `go get` does not look there — instead, it looks for a module at the repo root that lacks a `go.mod` file.
And, indeed, the repo root does lack a `go.mod` file, so the `go` command interprets it as a module.

Since `v1.10.1` does have a `go.mod` file, `go get -u` should ignore the `+incompatible` versions as of Go 1.14.
https://golang.org/issue/31866 would also catch this particular case.

However, there is still a remaining bug, which I've filed as https://golang.org/issue/36438.
I'm not sure whether we'll fix that one, though: we would give better diagnostics for some confusing situations, but at the cost of invalidating some versions that were previously usable.


On Mon, Jan 6, 2020 at 1:53 PM Jérôme LAFORGE <jerome....@gmail.com> wrote:
I use this version:
go version go1.13.5 linux/amd64

--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/eRt5gD5pIhQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/d8e502c5-80cf-4aab-943c-0216b15afa33%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages