-
Notifications
You must be signed in to change notification settings - Fork 352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid use of json.NewDecoder #313
Conversation
Avoid use of json.NewDecoder if not needed. Resolves #303.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good in theory. The extra almost duplicated code is a bit annoying, but the performance gain should be visible. I had some numbers in the original issue, but I will try to do some performance comparisons with this next patch week.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Numbers look good. As expected, we have a good performance gain (and slightly less allocations).
Before:
BenchmarkParseUnverified/map_claims-8 1497346 792.5 ns/op 2208 B/op 35 allocs/op
BenchmarkParseUnverified/map_claims#01-8 1343728 886.2 ns/op 2344 B/op 41 allocs/op
BenchmarkParseUnverified/map_claims#02-8 1270246 939.6 ns/op 2344 B/op 41 allocs/op
BenchmarkParseUnverified/map_claims#03-8 1211380 1045 ns/op 2447 B/op 46 allocs/op
BenchmarkParseUnverified/map_claims#04-8 1528545 787.7 ns/op 2208 B/op 35 allocs/op
BenchmarkParseUnverified/map_claims#05-8 1519468 796.2 ns/op 2208 B/op 35 allocs/op
BenchmarkParseUnverified/map_claims#06-8 1500554 822.2 ns/op 2208 B/op 35 allocs/op
BenchmarkParseUnverified/map_claims#07-8 1485224 814.9 ns/op 2208 B/op 35 allocs/op
BenchmarkParseUnverified/map_claims#08-8 1446320 830.3 ns/op 2208 B/op 35 allocs/op
BenchmarkParseUnverified/map_claims#09-8 1475530 815.5 ns/op 2208 B/op 35 allocs/op
BenchmarkParseUnverified/map_claims#10-8 1493253 848.2 ns/op 2208 B/op 35 allocs/op
BenchmarkParseUnverified/map_claims#11-8 1475796 818.6 ns/op 2208 B/op 35 allocs/op
BenchmarkParseUnverified/map_claims#12-8 1433794 817.1 ns/op 2208 B/op 35 allocs/op
BenchmarkParseUnverified/map_claims#13-8 1292407 945.9 ns/op 2344 B/op 41 allocs/op
BenchmarkParseUnverified/map_claims#14-8 1301379 941.3 ns/op 2344 B/op 41 allocs/op
BenchmarkParseUnverified/map_claims#15-8 1000000 1033 ns/op 2448 B/op 46 allocs/op
BenchmarkParseUnverified/map_claims#16-8 1293612 925.4 ns/op 2344 B/op 41 allocs/op
BenchmarkParseUnverified/registered_claims-8 1417246 844.8 ns/op 2231 B/op 35 allocs/op
BenchmarkParseUnverified/registered_claims#01-8 1394887 868.4 ns/op 2280 B/op 39 allocs/op
BenchmarkParseUnverified/registered_claims#02-8 1286151 950.9 ns/op 2344 B/op 42 allocs/op
BenchmarkParseUnverified/registered_claims#03-8 1447845 822.4 ns/op 2208 B/op 34 allocs/op
BenchmarkParseUnverified/registered_claims#04-8 1294418 934.2 ns/op 2336 B/op 41 allocs/op
BenchmarkParseUnverified/registered_claims#05-8 1378839 853.6 ns/op 2224 B/op 35 allocs/op
BenchmarkParseUnverified/registered_claims#06-8 1390922 860.2 ns/op 2224 B/op 35 allocs/op
After:
BenchmarkParseUnverified/map_claims-8 1917262 668.2 ns/op 1464 B/op 32 allocs/op
BenchmarkParseUnverified/map_claims#01-8 1561243 714.7 ns/op 1600 B/op 38 allocs/op
BenchmarkParseUnverified/map_claims#02-8 1691029 785.0 ns/op 1592 B/op 38 allocs/op
BenchmarkParseUnverified/map_claims#03-8 1548421 836.3 ns/op 1696 B/op 43 allocs/op
BenchmarkParseUnverified/map_claims#04-8 1874676 614.6 ns/op 1464 B/op 32 allocs/op
BenchmarkParseUnverified/map_claims#05-8 1958278 630.7 ns/op 1464 B/op 32 allocs/op
BenchmarkParseUnverified/map_claims#06-8 1834294 611.8 ns/op 1464 B/op 32 allocs/op
BenchmarkParseUnverified/map_claims#07-8 1884421 638.2 ns/op 1464 B/op 32 allocs/op
BenchmarkParseUnverified/map_claims#08-8 1887714 653.2 ns/op 1464 B/op 32 allocs/op
BenchmarkParseUnverified/map_claims#09-8 1747687 680.3 ns/op 1464 B/op 32 allocs/op
BenchmarkParseUnverified/map_claims#10-8 1887813 658.6 ns/op 1464 B/op 32 allocs/op
BenchmarkParseUnverified/map_claims#11-8 1830204 647.6 ns/op 1464 B/op 32 allocs/op
BenchmarkParseUnverified/map_claims#12-8 1420887 898.6 ns/op 2208 B/op 35 allocs/op
BenchmarkParseUnverified/map_claims#13-8 1247702 953.2 ns/op 2344 B/op 41 allocs/op
BenchmarkParseUnverified/map_claims#14-8 1000000 1060 ns/op 2344 B/op 41 allocs/op
BenchmarkParseUnverified/map_claims#15-8 1000000 1077 ns/op 2448 B/op 46 allocs/op
BenchmarkParseUnverified/map_claims#16-8 1227679 1009 ns/op 2344 B/op 41 allocs/op
BenchmarkParseUnverified/registered_claims-8 1281345 897.1 ns/op 2231 B/op 35 allocs/op
BenchmarkParseUnverified/registered_claims#01-8 1312928 902.9 ns/op 2280 B/op 39 allocs/op
BenchmarkParseUnverified/registered_claims#02-8 1236802 1110 ns/op 2344 B/op 42 allocs/op
BenchmarkParseUnverified/registered_claims#03-8 1448676 838.2 ns/op 2208 B/op 34 allocs/op
BenchmarkParseUnverified/registered_claims#04-8 1000000 1041 ns/op 2336 B/op 41 allocs/op
BenchmarkParseUnverified/registered_claims#05-8 1692842 685.4 ns/op 1480 B/op 32 allocs/op
BenchmarkParseUnverified/registered_claims#06-8 1792794 669.0 ns/op 1480 B/op 32 allocs/op
For example registered_claims#05-8 and registered_claims#06-8 are the ones not using JSON number, and those seem to be almost 20% faster and less allocations (32 vs 35)
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [github.com/golang-jwt/jwt/v5](https://togithub.com/golang-jwt/jwt) | require | minor | `v5.0.0` -> `v5.1.0` | | golang.org/x/crypto | require | minor | `v0.14.0` -> `v0.15.0` | | golang.org/x/net | require | minor | `v0.17.0` -> `v0.18.0` | | golang.org/x/oauth2 | require | minor | `v0.13.0` -> `v0.14.0` | | golang.org/x/term | require | minor | `v0.13.0` -> `v0.14.0` | --- ### Release Notes <details> <summary>golang-jwt/jwt (github.com/golang-jwt/jwt/v5)</summary> ### [`v5.1.0`](https://togithub.com/golang-jwt/jwt/releases/tag/v5.1.0) [Compare Source](https://togithub.com/golang-jwt/jwt/compare/v5.0.0...v5.1.0) #### What's Changed - Using jwt's native `ErrInvalidType` instead of `json.UnsupportedTypeError` by [@​oxisto](https://togithub.com/oxisto) in [https://github.com/golang-jwt/jwt/pull/316](https://togithub.com/golang-jwt/jwt/pull/316) - Fix typos in comments and test names by [@​alexandear](https://togithub.com/alexandear) in [https://github.com/golang-jwt/jwt/pull/317](https://togithub.com/golang-jwt/jwt/pull/317) - Format: add whitespaces, remove empty lines by [@​alexandear](https://togithub.com/alexandear) in [https://github.com/golang-jwt/jwt/pull/319](https://togithub.com/golang-jwt/jwt/pull/319) - Refactor example: use io.ReadAll instead of io.Copy by [@​alexandear](https://togithub.com/alexandear) in [https://github.com/golang-jwt/jwt/pull/320](https://togithub.com/golang-jwt/jwt/pull/320) - Refactor code by using switch instead of if-else by [@​alexandear](https://togithub.com/alexandear) in [https://github.com/golang-jwt/jwt/pull/318](https://togithub.com/golang-jwt/jwt/pull/318) - A quick way to validate token string by [@​dcalsky](https://togithub.com/dcalsky) in [https://github.com/golang-jwt/jwt/pull/302](https://togithub.com/golang-jwt/jwt/pull/302) - Refactor: remove unnecessary \[]byte conversion to string by [@​alexandear](https://togithub.com/alexandear) in [https://github.com/golang-jwt/jwt/pull/330](https://togithub.com/golang-jwt/jwt/pull/330) - Refactor: compare strings with strings.EqualFold by [@​alexandear](https://togithub.com/alexandear) in [https://github.com/golang-jwt/jwt/pull/329](https://togithub.com/golang-jwt/jwt/pull/329) - Avoid use of json.NewDecoder by [@​craigpastro](https://togithub.com/craigpastro) in [https://github.com/golang-jwt/jwt/pull/313](https://togithub.com/golang-jwt/jwt/pull/313) - Update ParseUnverified godoc by [@​duhaesbaert](https://togithub.com/duhaesbaert) in [https://github.com/golang-jwt/jwt/pull/341](https://togithub.com/golang-jwt/jwt/pull/341) - Update ci workflows (add go1.21) by [@​mfridman](https://togithub.com/mfridman) in [https://github.com/golang-jwt/jwt/pull/345](https://togithub.com/golang-jwt/jwt/pull/345) - Bump actions/checkout from 3 to 4 by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/golang-jwt/jwt/pull/346](https://togithub.com/golang-jwt/jwt/pull/346) - Key rotation with VerificationKeySet by [@​mfridman](https://togithub.com/mfridman) in [https://github.com/golang-jwt/jwt/pull/344](https://togithub.com/golang-jwt/jwt/pull/344) - Add explicit ClaimsValidator implementation check for custom claims by [@​epelc](https://togithub.com/epelc) in [https://github.com/golang-jwt/jwt/pull/343](https://togithub.com/golang-jwt/jwt/pull/343) - feat: allow making exp claim required by [@​tareksha](https://togithub.com/tareksha) in [https://github.com/golang-jwt/jwt/pull/351](https://togithub.com/golang-jwt/jwt/pull/351) - Add error handling to examples by [@​craigpastro](https://togithub.com/craigpastro) in [https://github.com/golang-jwt/jwt/pull/312](https://togithub.com/golang-jwt/jwt/pull/312) #### New Contributors - [@​alexandear](https://togithub.com/alexandear) made their first contribution in [https://github.com/golang-jwt/jwt/pull/317](https://togithub.com/golang-jwt/jwt/pull/317) - [@​dcalsky](https://togithub.com/dcalsky) made their first contribution in [https://github.com/golang-jwt/jwt/pull/302](https://togithub.com/golang-jwt/jwt/pull/302) - [@​craigpastro](https://togithub.com/craigpastro) made their first contribution in [https://github.com/golang-jwt/jwt/pull/313](https://togithub.com/golang-jwt/jwt/pull/313) - [@​duhaesbaert](https://togithub.com/duhaesbaert) made their first contribution in [https://github.com/golang-jwt/jwt/pull/341](https://togithub.com/golang-jwt/jwt/pull/341) - [@​epelc](https://togithub.com/epelc) made their first contribution in [https://github.com/golang-jwt/jwt/pull/343](https://togithub.com/golang-jwt/jwt/pull/343) - [@​tareksha](https://togithub.com/tareksha) made their first contribution in [https://github.com/golang-jwt/jwt/pull/351](https://togithub.com/golang-jwt/jwt/pull/351) **Full Changelog**: golang-jwt/jwt@v5.0.0...v5.1.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "before 4am" (UTC), Automerge - "before 4am" (UTC). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://togithub.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/woodpecker-ci/woodpecker). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40Ni4wIiwidXBkYXRlZEluVmVyIjoiMzcuNDYuMCIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
[![Mend Renovate logo banner](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [github.com/golang-jwt/jwt/v5](https://togithub.com/golang-jwt/jwt) | require | minor | `v5.0.0` -> `v5.1.0` | --- ### Release Notes <details> <summary>golang-jwt/jwt (github.com/golang-jwt/jwt/v5)</summary> ### [`v5.1.0`](https://togithub.com/golang-jwt/jwt/releases/tag/v5.1.0) [Compare Source](https://togithub.com/golang-jwt/jwt/compare/v5.0.0...v5.1.0) #### What's Changed - Using jwt's native `ErrInvalidType` instead of `json.UnsupportedTypeError` by [@​oxisto](https://togithub.com/oxisto) in [https://github.com/golang-jwt/jwt/pull/316](https://togithub.com/golang-jwt/jwt/pull/316) - Fix typos in comments and test names by [@​alexandear](https://togithub.com/alexandear) in [https://github.com/golang-jwt/jwt/pull/317](https://togithub.com/golang-jwt/jwt/pull/317) - Format: add whitespaces, remove empty lines by [@​alexandear](https://togithub.com/alexandear) in [https://github.com/golang-jwt/jwt/pull/319](https://togithub.com/golang-jwt/jwt/pull/319) - Refactor example: use io.ReadAll instead of io.Copy by [@​alexandear](https://togithub.com/alexandear) in [https://github.com/golang-jwt/jwt/pull/320](https://togithub.com/golang-jwt/jwt/pull/320) - Refactor code by using switch instead of if-else by [@​alexandear](https://togithub.com/alexandear) in [https://github.com/golang-jwt/jwt/pull/318](https://togithub.com/golang-jwt/jwt/pull/318) - A quick way to validate token string by [@​dcalsky](https://togithub.com/dcalsky) in [https://github.com/golang-jwt/jwt/pull/302](https://togithub.com/golang-jwt/jwt/pull/302) - Refactor: remove unnecessary \[]byte conversion to string by [@​alexandear](https://togithub.com/alexandear) in [https://github.com/golang-jwt/jwt/pull/330](https://togithub.com/golang-jwt/jwt/pull/330) - Refactor: compare strings with strings.EqualFold by [@​alexandear](https://togithub.com/alexandear) in [https://github.com/golang-jwt/jwt/pull/329](https://togithub.com/golang-jwt/jwt/pull/329) - Avoid use of json.NewDecoder by [@​craigpastro](https://togithub.com/craigpastro) in [https://github.com/golang-jwt/jwt/pull/313](https://togithub.com/golang-jwt/jwt/pull/313) - Update ParseUnverified godoc by [@​duhaesbaert](https://togithub.com/duhaesbaert) in [https://github.com/golang-jwt/jwt/pull/341](https://togithub.com/golang-jwt/jwt/pull/341) - Update ci workflows (add go1.21) by [@​mfridman](https://togithub.com/mfridman) in [https://github.com/golang-jwt/jwt/pull/345](https://togithub.com/golang-jwt/jwt/pull/345) - Bump actions/checkout from 3 to 4 by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/golang-jwt/jwt/pull/346](https://togithub.com/golang-jwt/jwt/pull/346) - Key rotation with VerificationKeySet by [@​mfridman](https://togithub.com/mfridman) in [https://github.com/golang-jwt/jwt/pull/344](https://togithub.com/golang-jwt/jwt/pull/344) - Add explicit ClaimsValidator implementation check for custom claims by [@​epelc](https://togithub.com/epelc) in [https://github.com/golang-jwt/jwt/pull/343](https://togithub.com/golang-jwt/jwt/pull/343) - feat: allow making exp claim required by [@​tareksha](https://togithub.com/tareksha) in [https://github.com/golang-jwt/jwt/pull/351](https://togithub.com/golang-jwt/jwt/pull/351) - Add error handling to examples by [@​craigpastro](https://togithub.com/craigpastro) in [https://github.com/golang-jwt/jwt/pull/312](https://togithub.com/golang-jwt/jwt/pull/312) #### New Contributors - [@​alexandear](https://togithub.com/alexandear) made their first contribution in [https://github.com/golang-jwt/jwt/pull/317](https://togithub.com/golang-jwt/jwt/pull/317) - [@​dcalsky](https://togithub.com/dcalsky) made their first contribution in [https://github.com/golang-jwt/jwt/pull/302](https://togithub.com/golang-jwt/jwt/pull/302) - [@​craigpastro](https://togithub.com/craigpastro) made their first contribution in [https://github.com/golang-jwt/jwt/pull/313](https://togithub.com/golang-jwt/jwt/pull/313) - [@​duhaesbaert](https://togithub.com/duhaesbaert) made their first contribution in [https://github.com/golang-jwt/jwt/pull/341](https://togithub.com/golang-jwt/jwt/pull/341) - [@​epelc](https://togithub.com/epelc) made their first contribution in [https://github.com/golang-jwt/jwt/pull/343](https://togithub.com/golang-jwt/jwt/pull/343) - [@​tareksha](https://togithub.com/tareksha) made their first contribution in [https://github.com/golang-jwt/jwt/pull/351](https://togithub.com/golang-jwt/jwt/pull/351) **Full Changelog**: golang-jwt/jwt@v5.0.0...v5.1.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "before 6am on Monday" in timezone Europe/Paris, Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/cozy/cozy-stack). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy41OS44IiwidXBkYXRlZEluVmVyIjoiMzcuNTkuOCIsInRhcmdldEJyYW5jaCI6Im1hc3RlciJ9-->
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [github.com/golang-jwt/jwt/v5](https://togithub.com/golang-jwt/jwt) | `v5.0.0` -> `v5.2.1` | [![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fgolang-jwt%2fjwt%2fv5/v5.2.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fgolang-jwt%2fjwt%2fv5/v5.2.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fgolang-jwt%2fjwt%2fv5/v5.0.0/v5.2.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fgolang-jwt%2fjwt%2fv5/v5.0.0/v5.2.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>golang-jwt/jwt (github.com/golang-jwt/jwt/v5)</summary> ### [`v5.2.1`](https://togithub.com/golang-jwt/jwt/releases/tag/v5.2.1) [Compare Source](https://togithub.com/golang-jwt/jwt/compare/v5.2.0...v5.2.1) #### What's Changed - chore: remove unnecessary conversions from tests by [@​estensen](https://togithub.com/estensen) in [https://github.com/golang-jwt/jwt/pull/370](https://togithub.com/golang-jwt/jwt/pull/370) - Trivial: Typo fix for ECDSA error message by [@​tjs-cinemo](https://togithub.com/tjs-cinemo) in [https://github.com/golang-jwt/jwt/pull/373](https://togithub.com/golang-jwt/jwt/pull/373) - Fix incorrect error return by [@​ss49919201](https://togithub.com/ss49919201) in [https://github.com/golang-jwt/jwt/pull/371](https://togithub.com/golang-jwt/jwt/pull/371) #### New Contributors - [@​tjs-cinemo](https://togithub.com/tjs-cinemo) made their first contribution in [https://github.com/golang-jwt/jwt/pull/373](https://togithub.com/golang-jwt/jwt/pull/373) - [@​ss49919201](https://togithub.com/ss49919201) made their first contribution in [https://github.com/golang-jwt/jwt/pull/371](https://togithub.com/golang-jwt/jwt/pull/371) **Full Changelog**: golang-jwt/jwt@v5.2.0...v5.2.1 ### [`v5.2.0`](https://togithub.com/golang-jwt/jwt/releases/tag/v5.2.0) [Compare Source](https://togithub.com/golang-jwt/jwt/compare/v5.1.0...v5.2.0) #### What's Changed - Exported `NewValidator` by [@​oxisto](https://togithub.com/oxisto) in [https://github.com/golang-jwt/jwt/pull/349](https://togithub.com/golang-jwt/jwt/pull/349) - Improve ErrInvalidKeyType error messages by [@​Laurin-Notemann](https://togithub.com/Laurin-Notemann) in [https://github.com/golang-jwt/jwt/pull/361](https://togithub.com/golang-jwt/jwt/pull/361) - Update MIGRATION_GUIDE.md by [@​jbarham](https://togithub.com/jbarham) in [https://github.com/golang-jwt/jwt/pull/363](https://togithub.com/golang-jwt/jwt/pull/363) #### New Contributors - [@​Laurin-Notemann](https://togithub.com/Laurin-Notemann) made their first contribution in [https://github.com/golang-jwt/jwt/pull/361](https://togithub.com/golang-jwt/jwt/pull/361) - [@​jbarham](https://togithub.com/jbarham) made their first contribution in [https://github.com/golang-jwt/jwt/pull/363](https://togithub.com/golang-jwt/jwt/pull/363) **Full Changelog**: golang-jwt/jwt@v5.1.0...v5.2.0 ### [`v5.1.0`](https://togithub.com/golang-jwt/jwt/releases/tag/v5.1.0) [Compare Source](https://togithub.com/golang-jwt/jwt/compare/v5.0.0...v5.1.0) #### What's Changed - Using jwt's native `ErrInvalidType` instead of `json.UnsupportedTypeError` by [@​oxisto](https://togithub.com/oxisto) in [https://github.com/golang-jwt/jwt/pull/316](https://togithub.com/golang-jwt/jwt/pull/316) - Fix typos in comments and test names by [@​alexandear](https://togithub.com/alexandear) in [https://github.com/golang-jwt/jwt/pull/317](https://togithub.com/golang-jwt/jwt/pull/317) - Format: add whitespaces, remove empty lines by [@​alexandear](https://togithub.com/alexandear) in [https://github.com/golang-jwt/jwt/pull/319](https://togithub.com/golang-jwt/jwt/pull/319) - Refactor example: use io.ReadAll instead of io.Copy by [@​alexandear](https://togithub.com/alexandear) in [https://github.com/golang-jwt/jwt/pull/320](https://togithub.com/golang-jwt/jwt/pull/320) - Refactor code by using switch instead of if-else by [@​alexandear](https://togithub.com/alexandear) in [https://github.com/golang-jwt/jwt/pull/318](https://togithub.com/golang-jwt/jwt/pull/318) - A quick way to validate token string by [@​dcalsky](https://togithub.com/dcalsky) in [https://github.com/golang-jwt/jwt/pull/302](https://togithub.com/golang-jwt/jwt/pull/302) - Refactor: remove unnecessary \[]byte conversion to string by [@​alexandear](https://togithub.com/alexandear) in [https://github.com/golang-jwt/jwt/pull/330](https://togithub.com/golang-jwt/jwt/pull/330) - Refactor: compare strings with strings.EqualFold by [@​alexandear](https://togithub.com/alexandear) in [https://github.com/golang-jwt/jwt/pull/329](https://togithub.com/golang-jwt/jwt/pull/329) - Avoid use of json.NewDecoder by [@​craigpastro](https://togithub.com/craigpastro) in [https://github.com/golang-jwt/jwt/pull/313](https://togithub.com/golang-jwt/jwt/pull/313) - Update ParseUnverified godoc by [@​duhaesbaert](https://togithub.com/duhaesbaert) in [https://github.com/golang-jwt/jwt/pull/341](https://togithub.com/golang-jwt/jwt/pull/341) - Update ci workflows (add go1.21) by [@​mfridman](https://togithub.com/mfridman) in [https://github.com/golang-jwt/jwt/pull/345](https://togithub.com/golang-jwt/jwt/pull/345) - Bump actions/checkout from 3 to 4 by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/golang-jwt/jwt/pull/346](https://togithub.com/golang-jwt/jwt/pull/346) - Key rotation with VerificationKeySet by [@​mfridman](https://togithub.com/mfridman) in [https://github.com/golang-jwt/jwt/pull/344](https://togithub.com/golang-jwt/jwt/pull/344) - Add explicit ClaimsValidator implementation check for custom claims by [@​epelc](https://togithub.com/epelc) in [https://github.com/golang-jwt/jwt/pull/343](https://togithub.com/golang-jwt/jwt/pull/343) - feat: allow making exp claim required by [@​tareksha](https://togithub.com/tareksha) in [https://github.com/golang-jwt/jwt/pull/351](https://togithub.com/golang-jwt/jwt/pull/351) - Add error handling to examples by [@​craigpastro](https://togithub.com/craigpastro) in [https://github.com/golang-jwt/jwt/pull/312](https://togithub.com/golang-jwt/jwt/pull/312) #### New Contributors - [@​alexandear](https://togithub.com/alexandear) made their first contribution in [https://github.com/golang-jwt/jwt/pull/317](https://togithub.com/golang-jwt/jwt/pull/317) - [@​dcalsky](https://togithub.com/dcalsky) made their first contribution in [https://github.com/golang-jwt/jwt/pull/302](https://togithub.com/golang-jwt/jwt/pull/302) - [@​craigpastro](https://togithub.com/craigpastro) made their first contribution in [https://github.com/golang-jwt/jwt/pull/313](https://togithub.com/golang-jwt/jwt/pull/313) - [@​duhaesbaert](https://togithub.com/duhaesbaert) made their first contribution in [https://github.com/golang-jwt/jwt/pull/341](https://togithub.com/golang-jwt/jwt/pull/341) - [@​epelc](https://togithub.com/epelc) made their first contribution in [https://github.com/golang-jwt/jwt/pull/343](https://togithub.com/golang-jwt/jwt/pull/343) - [@​tareksha](https://togithub.com/tareksha) made their first contribution in [https://github.com/golang-jwt/jwt/pull/351](https://togithub.com/golang-jwt/jwt/pull/351) **Full Changelog**: golang-jwt/jwt@v5.0.0...v5.1.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/infratographer/x). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yNjkuMiIsInVwZGF0ZWRJblZlciI6IjM3LjI2OS4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Avoid use of json.NewDecoder if not needed.
I was hanging around here and I noticed #303. This is an attempt to address it. Please let me know what you think. Thanks!
Resolves #303.