-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Support Go Modules #366
Comments
Hi, i can not build. get the error:
And i got 2 redigo in my go.mod...
go version: v1.11 |
@huaguoping Use github.com/garyburd/redigo v1.6.0 instead of v2.0.0. Better yet, use this package. |
Thx. 👍 |
Per "semantic import versioning", introduced with go modules in go 1.11, incrementing the major version of a module above 1 requires a new import path. See:
Module compatibility and semantic versioning The preferred way to do this is usually to create a |
The challenge is that the repository is already v2, because it was tagged
as such well before Modules existed (and they are still not “final”).
You could publish a v2.0.1 and update the import path, but at risk of
breaking existing users & module users alike.
…On Fri, Nov 30, 2018 at 3:07 PM John Refior ***@***.***> wrote:
Per "semantic import versioning", introduced with go modules in go 1.11,
incrementing the major version of a module above 1 requires a new import
path. See:
In semantic versioning, changing the major version number indicates a lack
of backwards compatibility with earlier versions. 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, and packages in that module would use that path as
their import path prefix, as in example.com/m/v2/sub/pkg. Including the
major version number in the module path and import paths in this way is
called "semantic import versioning".
Module compatibility and semantic versioning
<https://golang.org/cmd/go/#hdr-Module_compatibility_and_semantic_versioning>
The preferred way to do this is usually to create a v2 branch, append /v2
to the module name (first line of the go.mod file), update import paths to
include the /v2, and tag a new v2.x.x release. That should be all that's
required. Imports that leave off the v2 will get the highest v1.x.x
availlable, while imports that include the v2 will get the highest v2.x.x
available.
See From Repository to Modules <https://research.swtch.com/vgo-module>.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#366 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AABIcDYwhnhJPPlm9NVo3g1__LnXc1_iks5u0Y_kgaJpZM4W31s->
.
|
Glide allows Go 1.5+ users to lock packages at specific versions. But if I understand this requirement correctly, you are also trying to support users of Go 1.8 and earlier who do not employ a dependency management tool, and will always just get "latest" with Does the current "latest" work for them, or are you trying to move them back to some previous version via the next release? While I personally prefer the v2 branch mechanism of moving to v2 with go modules, in some situations it only works if you are following semantic versioning and assuming that users of older versions of Go can/will/should obtain an older release tag that works for their version. Here it sounds like you want to be backward compatible even when that assumption is not true (what Go creators wanted in the beginning). Then again, you have somewhat isolated internal import paths that would be affected by a Regarding support for Go modules in that proposal, I think as long as your Alternatively, I think the directory approach to moving to v2 with go modules probably does meet your goals (if I understand the situation correctly). As Russ Cox described it:
See From Repository to Modules In that case, you could choose (by leaving the code outside the Then inside the |
The current latest works Go 1.5 and up.
…On Sun, Dec 2, 2018 at 6:37 AM John Refior ***@***.***> wrote:
Existing users do not need to change code or tools to continue using the
current version of the package. This includes users on Go 1.8 and earlier,
users who fetch the code with go get, etc.
Glide allows Go 1.5+ users to lock packages at specific versions. But if I
understand this requirement correctly, you are also trying to support users
of Go 1.8 and earlier who do not employ a dependency management tool, and
will always just get "latest" with go get -- is that correct?
Does the current "latest" work for them, or are you trying to move them
back to some previous version via the next release?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#366 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AACCg3iWVKvJ0eyPrbsRhxCSiHvqBixFks5u0-WSgaJpZM4W31s->
.
|
@jrefior: I updated the issue to clarify where we are today and what I see as the requirements. Let me know if that does not answer your questions. All: I deleted comments regarding an unrelated issue. Does it work to orphan v2.0.0 and continue continue releases on v1.x.x where a go.mod file can be added seamlessly? |
You've mentioned orphaning v2.0.0. If you leave the v2.0.0 tag in place and continue development on v1.x.x, someone or some dependency management tool will pull v2.0.0 when trying to get latest. So you'll have to delete the v2.0.0 tag, and create a new 1.x.0 tag in it's place. Here I tried to do that. I forked the repository, deleted the v2.0.0 tag ( If you're willing to delete the v2.0.0 tag, then this may accomplish more of your goals than other solutions. Users may have to make changes in their dependency management configuration, but not to their code. Otherwise at some point users of new versions of Go will have to change their import path to include the What do you think? |
What happens to users who pulled v2.0.0 already, and have it in their
dependency manifest?
…On Sat, Jan 19, 2019 at 11:23 AM John Refior ***@***.***> wrote:
You've mentioned orphaning v2.0.0. If you leave the v2.0.0 tag in place
and continue development on v1.x.x, someone or some dependency management
tool will pull v2.0.0 when trying to get latest. So you'll have to delete
the v2.0.0 tag, and create a new 1.x.0 tag in it's place.
Here I tried to do that. I forked the repository, deleted the v2.0.0 tag (git
push --delete origin v2.0.0), added a go.mod file, and tagged a new
v1.7.0 release: https://github.com/jrefior/redigo . You can try pulling
it down or using various dependency management tools with different version
specifications for testing if you like.
If you're willing to delete the v2.0.0 tag, then I think this accomplishes
more of your goals than any other solution. Otherwise at some point users
of new versions of Go will have to change their import path to include the
/v2.
But if you're willing to require the /v2 import path to get the latest
code -- and not specifying v2 will just give you the highest v1.x.x version
-- I think the branch model with build constraints will also work.
What do you think?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#366 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AABIcFYcGZ_mM6wmm_3R06P2zCx7HFZZks5vE3CvgaJpZM4W31s->
.
|
Right, that's the question, because that's where there's possible downside. And the reason for doing some testing with different dependency management tools. So for example, if I'm on go 1.11.4, and I "restore" v2.0.0 by deleting the go.mod file and committing and tagging, then import jrefior/redigo from some other project via go get, I'll see this:
Now when I delete tag v2.0.0, and commit the go.mod file again and tag v1.8.0, now I try to build my test project again:
The build just works. But that's because it's loading
And the binary is not built. So then the user has to take some action to resolve the problem. In this situation a In my view, that's not a great user experience. This test could be repeated with glide and dep and other dependency management tools. Unfortunately I think trying to continue with development/maintenance on v1.x.x only without deleting v2.0.0 is probably worse, as many users trying to get latest will inadvertently wind up with v2.0.0, failing silently to get the latest code. To avoid both of those you can set the module name to |
How about this:
Tests will fail in the v1 branch. Everything else should work. |
Since it appears you intend for most consumers to use the I would imagine that the If this is a viable solution, I think #413 can serve for the |
@arnottcr Because it was a mistake to create the v2 tag, I'd like to ignore it. The problem is that people will assume that v2 is better than v1. The status of v2 can be explained in the README, but that will only help those who actually read the file. Perhaps the best option is to maintain v1 and v2 in parallel with v1 as the main line of development, A script can be written to merge changes from v1 to v2 and create the v2 tags as needed. This is the opposite of what I described here. |
That makes sense, I think in that case you may want to consider the major subdirectory option and use type aliases in conjunction with a tool like goforward to make things easier on yourself. The only breakage you could see, is for people using tools like #413 mocks up this proposal, but it could be changed to use |
Agreed that maybe we can just get a v3. Now every time I do things like |
Is there any reason to just not delete the |
It's not 100% ideal but a v3 may be the lesser of all evils, thoughts? |
Tags MUST not be deleted per the semver spec, it also cannot be deleted from the module proxy, so the delete will be a noop. |
Sounds good to me. Better than the current situation. |
Fixes gomodule#366
Fixes gomodule#366
Fixes gomodule#366
Fixes gomodule#366
(Just fyi) To use the latest version of this module you can fallback to pseudoversioning:
and then just replace your original gomodule/redigo in |
Noticed this post from rsc in another thread on adding Go Modules support to an open source package, and thought some people considering options in this issue might find it helpful: |
You could just create a long lived v2 branch with a go.mod with the proper v2 module name, and then merge all released changes into that branch from master every time you cut a new v1 release... then use the v2 branch to make releases for v2...keeping them in sync with the v1 releases. This would allow |
Fixes gomodule#366
Fixes gomodule#366
Fixes gomodule#366
Add support for go mod The correct behaviour of this relies on go1.14 https://golang.org/doc/go1.14#incompatible-versions Fixes #366
This repo was moved from here from garyburd/redigo. At the time of the move, I made some minor breaking changes to the API and tagged a v2.0.0 release.
The v2.0.0 release turned out to be a problem when Go Modules were introduced. It's now clear that I should have deleted previous v1.x.x releases from the repo and tagged a new v1.0.0 release.
I was my intent that this repo have one major semantic version until the next breaking API change is made. Let's call the major semantic version as of today as version N.
It's possible that users who employ a dependency management tool are using the tags copied over from garyburd/redigo. These users are on major version N-1.Edit: These versions do not compile because they have a package import comment for garyburd/redigo. It's safe to assume that there are no users of these versions.Users of Go 1.5+ who do not employ a dependency management tool should continue to get the latest of major version N. This works today and should continue to be supported until Go Modules is widely adopted.
Users who opt into Go Modules should not need to change their code.
Because I expect Go Modules to be widely adopted before major version N+1 of this package is created, it's acceptable to require a dependency management tool to get version N+1.
Adding a go.mod file to a v2.x.x release changes the path of the package to github.com/gomodule/redigo/v2. This requires a change to all importers of the packages and does not work for users on Go 1.8 and earlier.
See previous discussion in #365 and #363.
The text was updated successfully, but these errors were encountered: