Skip to content
This repository has been archived by the owner on May 21, 2022. It is now read-only.

Go Modules support #301

Closed
sspaink opened this issue Oct 23, 2018 · 11 comments
Closed

Go Modules support #301

sspaink opened this issue Oct 23, 2018 · 11 comments
Milestone

Comments

@sspaink
Copy link
Contributor

sspaink commented Oct 23, 2018

Is there a plan to include go modules support?

I wouldn't mind making a pull request, looks like the project would just need to include a go.mod and go.sum file.

@gilcrest
Copy link

Is there a plan to include go modules support?

I wouldn't mind making a pull request, looks like the project would just need to include a go.mod and go.sum file.

I would love this as well, but given this library is on v3.2.0 I think there would need to be changes to adhere to the Semantic versioning rules of modules. I think a new package needs to be created in order to adhere to these rules, so that we're importing "github.com/dgrijalva/jwt-go/v3" instead of "github.com/dgrijalva/jwt-go" as we do today. I could be wrong about this...

From https://github.com/golang/go/wiki/Modules#semantic-import-versioning

As a result of semantic import versioning, code opting in to Go modules must comply with these rules:

Follow semantic versioning (with tags such as v1.2.3).
If the module is version v2 or higher, the major version of the module must be included in both the module path in the go.mod file (e.g., module example.com/my/mod/v2) and the package import path (e.g., import "example.com/my/mod/v2/foo").

@jesusvazquez
Copy link

jesusvazquez commented Apr 7, 2019

@dgrijalva any plans to do this? I think the community would love it.

Here are some duplicates:

Also as an example looks like @vladimiroff already did something like this in his fork:

@dgrijalva dgrijalva added this to the 4.0.0 milestone Apr 8, 2019
@dgrijalva
Copy link
Owner

Now that the community seems to have landed on go mod, I think it's time to add support. I don't believe we can do so in a backwards compatible way, so this will land in v4.

@dgrijalva
Copy link
Owner

This is landed on v4 branch

@omerlh
Copy link

omerlh commented May 23, 2019

Is there a way to use it v4? I couldn't find a release...

@gilcrest
Copy link

Is there a way to use it v4? I couldn't find a release...

Hi @omerlh - there is a v4 release and it has a go.mod file here. Hope this helps!

@omerlh
Copy link

omerlh commented May 23, 2019

Sorry, I'm pretty new to go - when trying to run go get github.com/dgrijalva/jwt-go it resolve to the latest v3 - how can I specific v4? I tried with v4.0.0 and it wasn't able to find a relevant version.

@gilcrest
Copy link

gilcrest commented May 23, 2019

No worries @omerlh - I have to run out for a bit, but check out https://blog.golang.org/using-go-modules and the section "Adding a dependency on a new major version". I haven't actually done this yet with jwt-go myself, but believe if you add an import like

import jwtv4 "github.com/dgrijalva/jwt-go/v4"

and then switch a piece of your code to use jwtv4 and it should automatically go grab the v4 branch...

It's that /v4 at the end of the import path that's important

@dgrijalva
Copy link
Owner

The v4 branch will undergo a few more changes before it's signed off. See the milestone for the list of remaining tickets.

@omerlh
Copy link

omerlh commented May 27, 2019

Thanks I'll try it out!

@quocnm0102
Copy link

Is there a plan to include go modules support?
I wouldn't mind making a pull request, looks like the project would just need to include a go.mod and go.sum file.

I would love this as well, but given this library is on v3.2.0 I think there would need to be changes to adhere to the Semantic versioning rules of modules. I think a new package needs to be created in order to adhere to these rules, so that we're importing "github.com/dgrijalva/jwt-go/v3" instead of "github.com/dgrijalva/jwt-go" as we do today. I could be wrong about this...

From https://github.com/golang/go/wiki/Modules#semantic-import-versioning

As a result of semantic import versioning, code opting in to Go modules must comply with these rules:

Follow semantic versioning (with tags such as v1.2.3).
If the module is version v2 or higher, the major version of the module must be included in both the module path in the go.mod file (e.g., module example.com/my/mod/v2) and the package import path (e.g., import "example.com/my/mod/v2/foo").

thank you so much. I spent one day for this issue until I saw you answer! :D

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants