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
proposal: cmd/go: optional mode - semantic import versioning #47034
Comments
I'm confused by this proposal. It seems to add more changes to the go.mod file which weren't discussed in the previous thread, so it seems like a fairly different proposal in general. |
Leaving aside the specific
For example, as I write this today the import path This proposal permits changing the major version of a module depended upon by another module with a This proposal makes it less possible to interpret a
Today, I can examine this file and state that the function I think this proposal would benefit from more explanation of the problem that it is intended to solve. It permits selecting the major version of a module to use without rewriting import paths, but it is not clear to me why rewriting import paths is a problem. Perhaps it is a problem, but if so, it would be best to first understand why. |
@mvdan I added what I believed was required from #44550 to reduce source tree changes when you intentionally wanted to ride between two versions. This is the addition of the
@neild with the keyword The
Yes.
I've updated the intention section of the proposal to more fully describe it. But effectively, |
I am sympathetic to (part of) the intention of this proposal, and whilst I am not completely convinced that this problem warrants a solution that fundamentally changes how module versioning currently works (albeit in an opt-in manner), my greater concern is that (if I have understood the proposal correctly) I don't believe that the proposed solution is an effective remedy to the stated problem. If I understand correctly, we currently have a situation where a module upgrade may be "partially applied" to another. This may happen either accidentally or intentionally, but in either case it is desirable to make the job of reviewing such changes easier and less error prone. My problem here is that the proposal only appears to offer a partial solution to this problem, and indeed only claims to "increase the ability" to review such changes and discover possible errors. Since there is no guarantee that every file that imports (any version of) If this situation warrants a solution at all, I would prefer one that properly covers the problem space, rather than one that offers an incremental improvement with no obvious route to a full solution. |
I'm retracting this because an issue that I believed was true within a definition of optional SIV inside the original ticket is untrue. A user has defined the naked import in their Therefore my thought that a necessity for an |
This proposal has been declined as retracted. |
Optional Semantic Import Versioning
Earlier proposal; trying to make it more formal, with definitions around the module file changes, and constraints. #44550
Additionally, made the behavior for resolution of naked imports a keyword you flip on for your project, so that if a change were made no old code would break.
Goal
To keep all current behavior and to allow the new naked import resolution to be entirely opt-in.
Even after a user has opted-in, allow the benefits of Semantic Import Versioning, such as utilizing two majors in the same compilation unit.
Intention
Across a large project, when you do a major version upgrade of Go code, many files are touched. If that contribution includes that only some source files in the compilation unit are being upgraded and others are being left, it requires manual review outside a code review tool because no lines of code have changed in those files. It can be difficult to pin down which files are being left because there are no source code changes to those files.
The driving purpose behind this change is to increase the ability to catch issues upon reviewing source code when upgrading a major version with Semantic Import Versioning where riding between two major versions was intentional.
Alongside these code review simplifications, the other aspect is allowing for semantic import versioning to also be closer and more in line with other package management solutions as an opt-in behavior for users.
Where the import path is resolved in combination with the package management manifest, in Go, the
go.mod
file.My assertion is that managing a project will be easier under the optional mode while allowing the same affordances for the compilation process that the current behavior does.
Module File Change Proposal
Define additional keyword in
go.mod
:optional
.Default value:
false
.Extend
require
syntax.require module-path module-version [default]*
The
default
tag is optional itself and used to indicate which version should resolve with the naked import when modules with duplicatemodule-path
components are found.Documentation:
Optional mode changes the
default
behavior ofv0/v1
resolution to instead resolve to the version described in thego.mod
file with the locality defined to the module compilation unit. Import statements that lack semantic import versions MUST resolve their version viago.mod
. In Optional mode, when two modules share the samemodule-path
one MUST have thedefault
identifier.Examples
Majority upgrade to
v2
with specific files staying atv1
Majority stays at
v1
with specific files upgrading tov2
.Constraints
Your choice of opting your module into optional mode impacts the handling of your own module but doesn't change the behavior outside your own compilation unit. SIV as it exists today would still apply outside the bounds of how your own module is handled.
Performance Impacts
Depending on the current resolution algorithm, this could make optional modules a boundary for optimizing a global resolution of package identifiers. However, given that multiple majors are allowed, I believe this will not be a blocking issue for this proposal.
The text was updated successfully, but these errors were encountered: