Skip to content
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

refactor(context): simplify "GetType()" functions #4080

Merged

Conversation

KaymeKaydex
Copy link
Contributor

This PR introduces a generic function, getTyped[T any], to simplify value retrieval in the Context struct. It replaces repetitive type assertions in the GetString and GetBool methods and adds comments to previously uncommented functions.

Benefits:
Reduces Code Duplication: Centralizes type assertions.
Enhances Readability: Simplifies method implementations and improves documentation.

@KaymeKaydex KaymeKaydex changed the title refactor: simplify GetType() functions refactor: simplify "GetType()" functions Oct 21, 2024
@appleboy appleboy added this to the v1.11 milestone Oct 25, 2024
@appleboy appleboy changed the title refactor: simplify "GetType()" functions refactor(context): simplify "GetType()" functions Oct 25, 2024
@appleboy
Copy link
Member

appleboy commented Oct 26, 2024

@KaymeKaydex Please rebase the master branch to start the CI build.

This PR introduces a generic function, getTyped[T any], to simplify value retrieval in the Context struct. It replaces repetitive type assertions in the GetString  GetBool etc. methods.
@KaymeKaydex KaymeKaydex force-pushed the refactor/typed-instead-dublicate branch from c23956d to 24db9b2 Compare October 26, 2024 10:19
@KaymeKaydex
Copy link
Contributor Author

@KaymeKaydex Please rebase the master branch to start the CI build.

done

Copy link

codecov bot commented Oct 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.93%. Comparing base (3dc1cd6) to head (24db9b2).
Report is 79 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4080      +/-   ##
==========================================
- Coverage   99.21%   98.93%   -0.28%     
==========================================
  Files          42       44       +2     
  Lines        3182     3387     +205     
==========================================
+ Hits         3157     3351     +194     
- Misses         17       25       +8     
- Partials        8       11       +3     
Flag Coverage Δ
?
-tags "sonic avx" 98.92% <100.00%> (?)
-tags go_json 98.92% <100.00%> (?)
-tags nomsgpack 98.92% <100.00%> (?)
go-1.18 ?
go-1.19 ?
go-1.20 ?
go-1.21 98.93% <100.00%> (-0.28%) ⬇️
go-1.22 98.93% <100.00%> (?)
macos-latest 98.93% <100.00%> (-0.28%) ⬇️
ubuntu-latest 98.93% <100.00%> (-0.28%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@appleboy appleboy merged commit c8a3adc into gin-gonic:master Oct 29, 2024
24 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants