golang-jwt / jwt

Go implementation of JSON Web Tokens (JWT).
https://golang-jwt.github.io/jwt/
MIT License
6.99k stars 336 forks source link

Token.New example is for the wrong func #338

Open notrobpike opened 1 year ago

notrobpike commented 1 year ago

The example for Token.New() actually demonstrates Token.NewWithClaims(). It should be demonstrating Token.New().

It additionally demonstrates signing, which I guess is ok but it seems out of scope, given that the signing example can just be part of the documentation for that method ...

oxisto commented 1 year ago

The example for Token.New() actually demonstrates Token.NewWithClaims(). It should be demonstrating Token.New().

It additionally demonstrates signing, which I guess is ok but it seems out of scope, given that the signing example can just be part of the documentation for that method ...

Which example are you exactly referring to? The ones in example_test.go use NewWithClaims, but are also named in this way.

notrobpike commented 1 year ago

https://github.com/golang-jwt/jwt/blob/v5.0.0/hmac_example_test.go#L26

which generates https://pkg.go.dev/github.com/golang-jwt/jwt/v5#New