Open KateGo520 opened 4 years ago
@jpillora @rotsix Could you help me review this issue? Thx :p
Thanks for the detailed writeup! I'd already moved to v2 before I switched to modules, though definitely missed this glaring issue - however I thinking of going for option 6 :P Delete all the v2 tags (since they're broken anyway) and re-tag as a v1. Thoughts?
@jpillora I'm worried that those repos that have used v2 tag will be break.
Can external repos use the v2 tag? I thought they recieve an invalid version error? Sorry I haven't tested any of this yet
On Sat, 25 Jul 2020 at 11:01, KateGo520 notifications@github.com wrote:
@jpillora https://github.com/jpillora I'm worried that those repos that have used v2 tag will be destroyed.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jpillora/media-sort/issues/28#issuecomment-663787259, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAE2X4Z3BZH6KHHERP2ZH53R5IVHJANCNFSM4PGKFMHQ .
main.go
package main
import mediasort "github.com/jpillora/media-sort/sort"
func main() {
c := mediasort.Config{}
c.DryRun = true
}
go.mod
module github.com/jpillora/foobar
go 1.14
then
$ go get -v .
go.mod again
module github.com/jpillora/foobar
go 1.14
require github.com/jpillora/media-sort v0.0.0-20200710203312-f7ab1e0e0471
and if you try to get a v2 tag directly
$ go get -v github.com/jpillora/media-sort@v2.6.2
go get github.com/jpillora/media-sort@v2.6.2: github.com/jpillora/media-sort@v2.6.2: invalid version: module contains a go.mod file, so major version must be compatible: should be v0 or v1, not v2
so I think it would be okay to remove the v2 tags
@jpillora OK,thank you for your reply.
Sorry hopefully will get around to this soon
Background
The
github.com/jpillora/media-sort
uses Go modules and the current release version isv2
. And it’s module path is"github.com/jpillora/media-sort"
, instead of"github.com/jpillora/media-sort/v2"
. 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 >= v2.3.0 of thejpillora/media-sort
:SO anyone using Go modules will not be able to easily use any newer version of
jpillora/media-sort
.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/jpillora/media-sort/v2
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 v2
subdirectory
(github.com/jpillora/media-sort/v2) and place a new go.mod file in that subdirectory. Themodule path
must end with/v2
. Copy or move the code into the v2 subdirectory. Updateimport statements
within the module to also use/v2
(import "github.com/jpillora/media-sort/v2/…"). Tag the release withv2.x.y
.3. Suggest your downstream module users use hash instead of a version tag.
If the standard rule of go modules conflicts with your development mode. Or not intended to be used as a library and does not make any guarantees about the API. 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/jpillora/media-sort@version-tag
, module users need to use this following way to get thejpillora/media-sort
: (1) Search for thetag
you want (in browser) (2) Get thecommit hash
for thetag
you want (3) Rungo get github.com/jpillora/media-sort@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 upgradejpillora/media-sort
.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