BTBurke / caddy-jwt

JWT middleware for the Caddy server
MIT License
113 stars 40 forks source link

go mod errors with "version "v3.7.2" invalid" when requiring this package #58

Closed hairyhenderson closed 4 years ago

hairyhenderson commented 4 years ago

With go modules, versions v2 and above of a module are supposed to have a trailing /vN on the module name.

When I try to require this package with the published module name, with a line like require github.com/BTBurke/caddy-jwt v3.7.2, I see the following error:

$ go get
go: finding github.com/BTBurke/caddy-jwt v3.7.2
go: finding github.com/BTBurke/caddy-jwt v3.7.2
go: errors parsing go.mod:
/tmp/foo/go.mod:3: require github.com/BTBurke/caddy-jwt: version "v3.7.2" invalid: module contains a go.mod file, so major version must be compatible: should be v0 or v1, not v3

If I try to use the "correct" name with require github.com/BTBurke/caddy-jwt/v3 v3.7.2, I see:

$ go get
go: github.com/BTBurke/caddy-jwt/v3@v3.7.2: go.mod has non-.../v3 module path "github.com/BTBurke/caddy-jwt" (and .../v3/go.mod does not exist) at revision v3.7.2

(yeah, go modules are a pain)

The fix, from what I can tell, is to alter the module line in go.mod to append /v3. I'll open a PR for that soon!

BTBurke commented 4 years ago

Thanks for taking a look at that. I think I might actually have to create a v3/ directory and copy the code in there to make modules happy. It's working right now with the Caddy build server, so I don't want that to be screwed up. I'm not sure what the build server is doing differently to get caddy to build with the current configuration. Give me some time to try your pull request and see if it works with the build server.

BTBurke commented 4 years ago

Fixed this in the latest commit. Thanks for the heads up.