refactor: add json tags and improve error message
Changes:
This PR introduces several improvements and refactors to enhance code quality and maintainability:
-
Added JSON Tags:
Addedjsonstruct tags to theJWKandJWKSstructs to ensure proper JSON serialization and deserialization. This improves compatibility with external APIs and ensures consistent JSON handling. -
Improved Error Messages:
Standardized error messages to follow Go conventions by removing capitalization and punctuation. This aligns with Go's idiomatic error handling practices. -
Handled Unused Variables:
Replaced unused variables with_to explicitly indicate that they are intentionally ignored. This improves code readability and avoids linter warnings. -
Replaced Deprecated
io/ioutil:
Updated the code to use theiopackage instead of the deprecatedio/ioutilpackage, as recommended in Go 1.16+. This ensures the codebase is up-to-date with modern Go practices. -
Fixed Typo:
Corrected the typo"unsigendToken"to"unsignedToken"for better code clarity and accuracy.
Why These Changes?
- JSON Tags: Ensures proper JSON marshaling/unmarshaling, which is critical for interacting with APIs.
- Error Messages: Improves consistency and readability of error messages, following Go's best practices.
- Unused Variables: Makes the code cleaner and more intentional by explicitly ignoring unused variables.
- Deprecated Packages: Future-proofs the code by replacing deprecated functionality with modern alternatives.
- Typo Fix: Improves code readability and avoids potential confusion.
Impact:
- No functional changes; this is purely a refactor for better code quality.
- Improves maintainability and aligns the codebase with Go's latest standards.
Testing:
- All existing tests should pass without modification.
- Manual testing was performed to ensure JSON serialization, error handling, and variable usage work as expected.