You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The github.com/zeromq/goczmq uses Go modules and the current release version is v4. And it’s module path is "github.com/zeromq/goczmq", instead of "github.com/zeromq/goczmq/v4". 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 >= v4.2.0 of the zeromq/goczmq:
$ go get github.com/zeromq/[email protected]
go: finding github.com/zeromq/goczmq v4.2.0
go: finding github.com/zeromq/goczmq v4.2.0
go get github.com/zeromq/[email protected]: github.com/zeromq/[email protected]: invalid version: module contains a go.mod file, so major version must be compatible: should be v0 or v1, not v4
run go get github.com/zeromq/goczmq, the version will stuck in v4.1.0:
SO anyone using Go modules will not be able to easily use any newer version of zeromq/goczmq.
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/zeromq/goczmq/v4 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…).
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 v4 subdirectory (github.com/zeromq/goczmq/v4) and place a new go.mod file in that subdirectory. The module path must end with /v4. Copy or move the code into the v4 subdirectory. Update import statements within the module to also use /v4 (import "github.com/zeromq/goczmq/v4/…"). Tag the release with v4.x.y.
3. Major version bump / repository change
Leave v4 as a dead version and bump to v5 with the path changes.
4. Remain unchanged
Don’t want to fix it. Not intended to be used as a library and does not make any guarantees about the API.
5. Suggest your downstream module users use hash instead of a version tag.
If the standard rule of go modules conflicts with your development mode. 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/zeromq/goczmq@version-tag, module users need to use this following way to get the zeromq/goczmq:
(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/zeromq/goczmq@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 zeromq/goczmq.
Pull <github.com/zeromq/goczmq@4715d4da6d4b> as a dep rather than
<gopkg.in/zeromq/goczmq.v4> for the reasons described here:
- <zeromq/goczmq#279> (see option 5)
Use zeromq/goczmq@4715d4da6d4 as a workaround until the upstream fixes
the issue.
Background
The
github.com/zeromq/goczmq
uses Go modules and the current release version isv4
. And it’s module path is"github.com/zeromq/goczmq"
, instead of"github.com/zeromq/goczmq/v4"
. It must comply with the specification of "Releasing Modules for v2 or higher" available in the Modules documentation. Quoting the specification:Steps to Reproduce
GO111MODULE=on, run
go get
targeting any version >= v4.2.0 of thezeromq/goczmq
:run
go get github.com/zeromq/goczmq
, the version will stuck in v4.1.0:SO anyone using Go modules will not be able to easily use any newer version of
zeromq/goczmq
.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 asgithub.com/zeromq/goczmq/v4
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: [1 module-unaware user, i.e., medmouine/zmq-go ]
https://github.com/medmouine/zmq-go/blob/master/Gopkg.toml#L34
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 v4
subdirectory
(github.com/zeromq/goczmq/v4) and place a new go.mod file in that subdirectory. Themodule path
must end with/v4
. Copy or move the code into the v4 subdirectory. Updateimport statements
within the module to also use/v4
(import "github.com/zeromq/goczmq/v4/…"). Tag the release withv4.x.y
.3. Major version bump / repository change
Leave
v4
as a dead version and bump to v5 with the path changes.4. Remain unchanged
Don’t want to fix it. Not intended to be used as a library and does not make any guarantees about the API.
5. Suggest your downstream module users use hash instead of a version tag.
If the standard rule of go modules conflicts with your development mode. 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/zeromq/goczmq@version-tag
, module users need to use this following way to get thezeromq/goczmq
:(1) Search for the
tag
you want (in browser)(2) Get the
commit hash
for thetag
you want(3) Run
go get github.com/zeromq/goczmq@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
zeromq/goczmq
.[*] You can see who will be affected here: [54 module users, e.g., usnistgov/dastard, DeviceFarmer/stf_ios_support, BeDreamCoder/locust-grpc…]
https://github.com/search?l=&o=desc&q=zeromq%2Fgoczmq+extension%3Ajson+extension%3Aconf+extension%3Atoml+extension%3Amod+extension%3Alock&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 2
can maximize your benefits and with minimal impacts to your downstream projects the ecosystem.References
The text was updated successfully, but these errors were encountered: