-
Notifications
You must be signed in to change notification settings - Fork 18k
How to avoid changing import paths for all source code files when upgrading major versions? #39376
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
Comments
Expectcasbin go.mod
Let's say v10.0.0 has been released in GitHub. Developer can get the dependency by |
What about large projects that use various versions of a package? Some packages break compatibility but instead migrate to newer version instantly we import both modules with different versions and add a notice to users that function is deprecated and will be dropped in X versions of the program. This is why we use the import with vX suffix in the source code, this allows to use two or more versions, example:
And go.mod:
Take this into account before make a proposal. |
Why we doesn't consider using go.mod:
|
There have been other issues on this topic before; have you tried searching? I would also suggest avoiding dramatic words like "disaster" when filing issues, so that we can just focus on the topic at hand. |
Also #25518 is related. Personally automates the version bump can be a nightmare. Not all developers breaks the compatibility, some deprecate functions before make code obsolete. |
@toothrot It seems to meet our expect. |
I would like to present my ideas here on how to install dependency of different version here. Let's assume there are multiple versions like Expectthings1If the user does not install this dependency, you can get the latest version of v2 by I hope that get the dependency by things2How resolve the import with vX suffix in the source code, example:
I hope that the get the dependency by I hope that the get the dependency by |
I'm not sure I understand. Do you mean that the package import path (in .go files import statements), the URL, and the module URL should refer to different packages? One of the primary design goals of modules is that different major versions are different packages to add clarity around breaking API changes. |
I see, but we need to update import path (in .go files import statements) when major version has been release. It looks unfriendly :( |
Hi there, Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only. For asking questions, see:
Please ask the question on one of the above forums. (Quoted from https://golang.org/wiki/Questions) |
In our code, we start to use Go modules for v2. Then we had a breaking change (casbin/casbin#472 (comment)) and based on Semver, we need to bump to v3. But this requires all our source code files to update all import paths from v2 to v3. And it also requires all our users' code that imports our library to change their import paths from v2 to v3. This is very inconvenient. And our users are not happy: casbin/casbin#478 (comment) It not only requires a lot of work for each major release, but also makes the git history looking bad.
For other package managers like npm (node.js) or pip (python), it just needs to update the version in the dependency file, no need to update source code.
Can we have a good solution to avoid changing import paths for all source code files for major version releases?
The text was updated successfully, but these errors were encountered: