karlseguin / ccache

A golang LRU Cache for high concurrency
MIT License
1.28k stars 119 forks source link

Latest tags are not compatible with Go module versioning scheme #42

Closed emiguens closed 4 years ago

emiguens commented 4 years ago

Go modules expects version tags to start with a v character.

Latest releases 2.0.4 and 2.0.5 does not contain it, resulting in the command go get github.com/karlseguin/ccache@latest resolve to version v2.0.3 (which does not contain a go.mod fille).

The fix would be as simple as creating the corresponding tags v2.0.4 and v2.0.5.

Thanks!

karlseguin commented 4 years ago

Sorry about that, don't do much go anymore so didn't know Updated.

prachiSharmaa commented 4 years ago

Publishing the tags alone does not solve this. See below,

> go get -v -u github.com/karlseguin/ccache/v2@v2.0.4
go: finding github.com v2.0.4
go: finding github.com/karlseguin/ccache v2.0.4
go: finding github.com/karlseguin v2.0.4
go: finding github.com/karlseguin/ccache/v2 v2.0.4
go: finding github.com/karlseguin/ccache/v2 v2.0.4
go: finding github.com/karlseguin/ccache v2.0.4
go get github.com/karlseguin/ccache/v2@v2.0.4: github.com/karlseguin/ccache@v2.0.4: invalid version: module contains a go.mod file, so major version must be compatible: should be v0 or v1, not v2

This is because gomodules major versions >=v2 need to have the version in the module path. In this case, the module path in go.mod should be github.com/karlseguin/ccache/v2. Details here.

karlseguin commented 4 years ago

So I pushed: https://github.com/karlseguin/ccache/commit/937ca294e671560fed89b5162fa3c3a60eb6a44b

if I create a new version, it should be all good? (I realize I should know this, but I have little desire to spend time understanding how Go finally decided to do this)

prachiSharmaa commented 4 years ago

Yes, this should work. Please create a new version from this. Thanks.

emiguens commented 4 years ago

Thanks @karlseguin for the fast response time 😄

It's not required for the module name to be changed (adding the /v2 suffix). Go modules can find the v2.x.x versions using the original module path.

Of course, adding the /v2 suffix to the module name, as you did in 937ca29, is the recommended way to go as the Go team is concerned, so I think this what the right call.

Now the examples in the README are wrong because they point to the "plain" v1 module. All imports and install instructions should be changed so they use github.com/karlseguin/ccache/v2 module path.