Reference:
https://research.swtch.com/vgo-principles
Go modules uses import path syntax called semantic import versioning, along with a new algorithm for selecting which versions to use, called minimal version selection.
For Go modules, the import compatibility rule can be written as:
If an old package and a new package have the same import path,
the new package must be backwards compatible with the old package.
https://research.swtch.com/vgo-principles
Go modules uses import path syntax called semantic import versioning, along with a new algorithm for selecting which versions to use, called minimal version selection.
For Go modules, the import compatibility rule can be written as:
If an old package and a new package have the same import path,
the new package must be backwards compatible with the old package.
Semantic import versioning:
(figures excerpted from https://research.swtch.com/vgo-principles)
For major version difference build:
e.g
For minor version difference build (consider repeatability):
The algorithm used for Go modules is very simple, despite the imposing name "minimal version selection"
It works like this:
- Each package specifies a minimum version of each dependency. For example, suppose B 1.3 requests D 1.3 or later, and C 1.8 requests D 1.4 or later.
- In Go modules, the go command prefers to use those exact versions, not the latest versions. If we’re building B by itself, we’ll use D 1.3. If we’re building C by itself, we’ll use D 1.4. The builds of these libraries are repeatable.
Also shown in the figure, if different parts of a build request different minimum versions, the go command uses the latest requested version.
The build of A sees requests for D 1.3 and D 1.4, and 1.4 is later than 1.3, so the build chooses D 1.4. That decision does not depend on whether D 1.5 and D 1.6 exist, so it does not change over time.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.