Closed KateGo520 closed 1 year ago
@elliotchance @jazzboME Could you help me review this issue? Thx :p
Thanks for the detailed information. Since I have no intend to support anything other than the latest release, removing the go.mod seems the most reasonable. I'm happy for you to put in a PR.
@elliotchance Thank you for your contribution
Any update here? I tried go get github.com/elliotchance/gedcom
, but it installs v38.0.0+incompatible
, not the latest v39.
@mattjohnsonpint what happens if you try go get github.com/elliotchance/gedcom@v39.5.3
?
go get github.com/elliotchance/gedcom@v39.5.3
gives:
go: github.com/elliotchance/gedcom@v39.5.3: invalid version: module contains a go.mod file, so module path must match major version ("github.com/elliotchance/gedcom/v39")
So I tried also:
go get github.com/elliotchance/gedcom/v39
but that gives:
go: module github.com/elliotchance/gedcom@upgrade found (v38.0.0+incompatible), but does not contain package github.com/elliotchance/gedcom/v39
Not sure what else to try. This is with Go 1.21.3 on MacOS.
I don't think resetting the versioning to 1.x makes sense. So the only reasonable option here it to move it into a v39 directory. Feel free to submit a PR.
First time doing something like this, so I hope I got it right. All modules build, and all tests pass.
Locally it works great, using a replace
statement in my own project's go.mod
:
replace github.com/elliotchance/gedcom/v39 => ../gedcom
Which I should be able to remove once this is merged.
It worked. I can now simply do:
go get github.com/elliotchance/gedcom/v39
And in my go.mod
, it adds:
require github.com/elliotchance/gedcom/v39 v39.6.0
Now I can import just fine and it works:
import "github.com/elliotchance/gedcom/v39"
Thanks!
Background
The github.com/elliotchance/gedcom uses Go modules and the current release stream version is v39. It must comply with the specification of "Releasing Modules for v2 or higher" available in the Modules documentation and enforced since the most recent versions of Go. The module path should be “github.com/elliotchance/gedcom/v39”. Quoting the specification:
Using
go get
(under go1.13 and go1.14) does not work for github.com/elliotchance/gedcom@v39.5.3 . I consider this a pretty high severity issue since not doing so prevents any other Go project also using Go Modules to properly requireelliotchance/gedcom
on version v39.5.3 as a dependency, resulting in errors like:SO anyone using Go modules will not be able to easily use any newer version of elliotchance/gedcom
Steps to Reproduce
Under a project making use of Go modules, run
go get
targeting any version >= v38.0.1 of the elliotchance/gedcom:Solution
1. Kill the go.mod files.
This would push them back to not being managed by Go modules (instead of incorrectly using Go modules). Importing specific versions would work, but they'd receive the
+incompatible
prefix and would need to be manually upgraded.Probably best option short-term -- better to not use Go modules than use it incorrectly. Also, best option for older branches/versions that aren't maintained.
2. Make breaking changes
Patch the
go.mod
file to declare themodule
asgithub.com/elliotchance/gedcom/v39
as per the specs. AND adjust all internal imports.There are two alternative mechanisms to release a v2 or higher module. Note that with both techniques, the new module release becomes available to consumers when the module author pushes
the new tags
. Using the example of creating a v3.0.0 release, the two options are:3. Major version bump / repository change
Leave
v39
as a dead version and bump to v40 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. Let the user change
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/elliotchance/gedcom@version-tag, the install procedure would be something like: (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/elliotchance/gedcom@commit-hash (4)Edit the go.mod file to put a comment about which version you actually used
References