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

Cannot get latest version: module contains a go.mod file, so module path should be github.com/kataras/go-sessions/v3 #26

Closed
KateGo520 opened this issue Jul 23, 2020 · 5 comments

Comments

@KateGo520
Copy link

KateGo520 commented Jul 23, 2020

Background

The github.com/kataras/go-sessions uses Go modules and the current release version is v3. And it’s module path is "github.com/kataras/go-sessions", instead of "github.com/kataras/go-sessions/v3". It must comply with the specification of "Releasing Modules for v2 or higher" available in the Modules documentation. Quoting the specification:

A package that has opted in to modules must include the major version in the import path to import any v2+ modules
To preserve import compatibility, the go command requires that modules with major version v2 or later use a module path with that major version as the final element. For example, version v2.0.0 of example.com/m must instead use module path example.com/m/v2.
https://github.com/golang/go/wiki/Modules#releasing-modules-v2-or-higher

Steps to Reproduce

GO111MODULE=on, run go get targeting any version >= v3.1.0 of the kataras/go-sessions:

$ go get github.com/kataras/go-sessions@v3.1.0
go: finding github.com/kataras/go-sessions v3.1.0
go: finding github.com/kataras/go-sessions v3.1.0
go get github.com/kataras/go-sessions@v3.1.0: github.com/kataras/go-sessions@v3.1.0: invalid version: module contains a go.mod file, so major version must be compatible: should be v0 or v1, not v3

run go get github.com/kataras/go-sessions, the version will stuck in v3.0.0:

$go get github.com/kataras/go-sessions
go: downloading github.com/kataras/go-sessions v0.0.7
go: downloading github.com/kataras/go-sessions v3.0.0+incompatible
go: github.com/kataras/go-sessions upgrade => v3.0.0+incompatible 

SO anyone using Go modules will not be able to easily use any newer version of kataras/go-sessions.

Solution

1. Kill the go.mod files, rolling back to GOPATH.

This would push them back to not being managed by Go modules (instead of incorrectly using Go modules).
Ensure compatibility for downstream module-aware projects and module-unaware projects projects

2. Fix module path to strictly follow SIV rules.

Patch the go.mod file to declare the module path as github.com/kataras/go-sessions/v3 as per the specs. And adjust all internal imports.
The downstream projects might be negatively affected in their building if they are module-unaware (Go versions older than 1.9.7 and 1.10.3; Or use third-party dependency management tools, such as: Dep, glide,govendor…).

[*] You can see who will be affected here: [17 module-unaware users, i.e., ttstringiot/golangiot, wjl2017/ttstringgolangiot, qnib/jupyterport ]
https://github.com/search?q=kataras%2Fgo-sessions+filename%3Avendor.conf+filename%3Avendor.json+filename%3Aglide.toml+filename%3AGodep.toml&type=Code

If you don't want to break the above repos. This method can provides better backwards-compatibility.
Release a v2 or higher module through the major subdirectory strategy: Create a new v3 subdirectory (github.com/kataras/go-sessions/v3) and place a new go.mod file in that subdirectory. The module path must end with /v3. Copy or move the code into the v3 subdirectory. Update import statements within the module to also use /v3 (import "github.com/kataras/go-sessions/v3/…"). Tag the release with v3.x.y.

3. Suggest your downstream module users use hash instead of a version tag.

If the standard rule of go modules conflicts with your development mode. Or not intended to be used as a library and does not make any guarantees about the API. So you can’t comply with the specification of "Releasing Modules for v2 or higher" available in the Modules documentation.
Regardless, since it's against one of the design choices of Go, it'll be a bit of a hack. Instead of go get github.com/kataras/go-sessions@version-tag, module users need to use this following way to get the kataras/go-sessions:
(1) Search for the tag you want (in browser)
(2) Get the commit hash for the tag you want
(3) Run go get github.com/kataras/go-sessions@commit-hash
(4) Edit the go.mod file to put a comment about which version you actually used
This will make it difficult for module users to get and upgrade kataras/go-sessions.

[*] You can see who will be affected here: [12 module users, e.g., AlexSwiss/go-login, dickyaryag6/Mini-e-wallet-using-GO, juliaveronica02/whatsapp-go]
https://github.com/search?o=desc&q=kataras%2Fgo-sessions+filename%3Ago.mod&s=indexed&type=Code

Summary

You can make a choice to fix DM issues by balancing your own development schedules/mode against the affects on the downstream projects.

For this issue, Solution 1 can maximize your benefits and with minimal impacts to your downstream projects the ecosystem.

References

@KateGo520
Copy link
Author

@kataras Could you help me review this issue? Thx :p

@kataras
Copy link
Owner

kataras commented Jul 24, 2020

I see @KateGo520, I know the issue, that's why last year Iris changed its import path to github.com/kataras/iris/v12. Thanks for reminding me about it. Just pushed a new v3.3.0 with import path of "github.com/kataras/go-sessions/v3".

On the upcoming release, we have some fixes and new features derived from Iris Sessions to push too. Stay tuned!

@KateGo520
Copy link
Author

KateGo520 commented Jul 25, 2020

@kataras Thank you for your work!

@kataras
Copy link
Owner

kataras commented Jul 26, 2020

You are welcome @KateGo520, I thank YOU!

@KateGo520 KateGo520 reopened this Aug 17, 2020
@KateGo520
Copy link
Author

Close this issue via edce9ac

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

2 participants