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

Update the go.mod file to include a /v3 at the end of the module path in the module directive #1244

Closed
Delphier opened this issue Jan 2, 2019 · 24 comments
Assignees

Comments

@Delphier
Copy link

Delphier commented Jan 2, 2019

go version: 1.11.4
go.mod enabled.

go get github.com/labstack/echo can't get the correct latest version. to get the version 3.3.5, but latest version is 3.3.8.

in the latest golang modules wiki, need to Update the go.mod file to include a /v3 at the end of the module path in the module directive.

please review:

https://github.com/golang/go/wiki/Modules#releasing-modules-v2-or-higher

@kodawah
Copy link

kodawah commented Jan 14, 2019

pinging @vishr since this is affecting a few of my projects as well ^^

@vishr
Copy link
Member

vishr commented Jan 14, 2019

Can you guys send a PR?
@im-kulikov Can you take care of this?

@im-kulikov
Copy link
Contributor

@vishr yeah)

@alexaandru
Copy link
Contributor

For the record, there's quite a bit of chatter about this in PR #1253
The short answer is: no, that is not so simple (just adding a /v3 suffix to existing v3.x line).

I did a tiny POC here: https://github.com/alexaandru/modules that replicated this precise issue: 1. have some V2+ branch; 2. add go.mod to it without suffix 3. add suffix later. The result when you try to import it (with /v2 suffix as it should be) is:

$ go build
go: downloading github.com/alexaandru/modules/v2 v2.2.0
build github.com/alexaandru/foobar: cannot find module for path github.com/alexaandru/modules/v2

so, half broken. It does resolve to the proper tag (v2.2.0, the last in the V2 line) however it also throws a cannot find module. The only resolution is to push the next vN, and release the vN at the same time with the vN.x.y tag (also tested on the POC repo and that worked as expected).

To wrap it up, we're working on it and hope to get it back working ASAP.

@Delphier
Copy link
Author

can we remove go.mod file on v3? start use go.mod from v4.

@im-kulikov
Copy link
Contributor

@Delphier The problem is not in go.mod

@alexaandru
Copy link
Contributor

@im-kulikov actually the problem is in go.mod - the fact that it was introduced from the start on a v2+ repo without the /vN suffix. I'm just not sure if removing it would fix the problem... need to try it out on my POC.

Just tested on my POC (https://github.com/alexaandru/modules), deleting go.mod will still not fix it. An app using Go modules will still fetch the version before go.mod was introduced (even if later, go.mod was removed, it still remains in history).

So V4 is the only way to go at this point.

@im-kulikov
Copy link
Contributor

@alexaandru I guess I didn't put it right. I meant that deleting the file doesn't solve the problem.

@Delphier
Copy link
Author

Delphier commented Jan 28, 2019

i fork echo and tested it:

- delete go.mod and go.sum
- release 3.3.10

run go get or go build or go mod tidy , the verson in go.mod is v3.3.10+incompatible.
Seems to be able to solve this problem temporarily.

@im-kulikov
Copy link
Contributor

Don't quite understand how removing go.mod solved the problem?

@im-kulikov
Copy link
Contributor

You can repeat the experiment without deleting the file.. I suppose the result will be the same..

@Delphier
Copy link
Author

Delphier commented Jan 28, 2019

Actually in go module mode:

module github.com/labstack/echo = module github.com/labstack/echo/v1
import github.com/labstack/echo = import github.com/labstack/echo/v1

just v1 is omitted.

becase tagged v1.x release with go.mod not found, v3.3.5 is last release without go.mod, so it is selected.
from golang help: Module compatibility and semantic versioning

Code written before the semantic import versioning convention was introduced may use major versions v2 and later to describe the same set of unversioned import paths as used in v0 and v1. To accommodate such code, if a source code repository has a v2.0.0 or later tag for a file tree with no go.mod, the version is considered to be part of the v1 module's available versions and is given an +incompatible suffix when converted to a module version, as in v2.0.0+incompatible. The +incompatible tag is also applied to pseudo-versions derived from such versions, as in v2.0.1-0.yyyymmddhhmmss-abcdefabcdef+incompatible.

@im-kulikov
Copy link
Contributor

hm.. it make sense.. @alexaandru what you think?

@alexaandru
Copy link
Contributor

Sounds good to me, it can't make things worse :-) Worst case scenario: it still pulls v3.3.5, at least that's how it did in my POC, but seems that @Delphier got a different outcome. I'll give it a try...

@alexaandru
Copy link
Contributor

Yes, this fixed it! Thanks @Delphier @im-kulikov ! :-) Please confirm it works on your end as well, so we can close this ticket. Thanks again!

@cubic3d
Copy link

cubic3d commented Jan 28, 2019

@alexaandru works fine for now, I get github.com/labstack/echo v3.3.10+incompatible

@alexaandru
Copy link
Contributor

Awesome, thank you very much @cubic3d ! Closing this.

@Delphier
Copy link
Author

works fine 😋

@alexaandru
Copy link
Contributor

Thank you @Delphier :-)

@im-kulikov
Copy link
Contributor

yay... it's work!

github.com/labstack/echo v3.3.10+incompatible // indirect

@alexaandru
Copy link
Contributor

Thanks @im-kulikov ! :)

@louiemiranda
Copy link

Hi, just trying to understand.

When I go get labstack/echo.

I get the following on go.mod

github.com/labstack/echo v3.3.10+incompatible

I was hoping to get the latest version of 4.x.

When I tried...

go get -u github.com/labstack/echo@v4.1.17
go get github.com/labstack/echo@v4.1.17: github.com/labstack/echo@v4.1.17: invalid version: module contains a go.mod file, so major version must be compatible: should be v0 or v1, not v4

I don't get it.

@Delphier
Copy link
Author

Delphier commented Nov 6, 2020

@louiemiranda Change github.com/labstack/echo to github.com/labstack/echo/v4 in go.mod and *.go file.

@louiemiranda
Copy link

thanks ! will try

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants