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: add json tags and improve error message #12

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fyvri
Copy link

@fyvri fyvri commented Jan 20, 2025

Changes:

This PR introduces several improvements and refactors to enhance code quality and maintainability:

  1. Added JSON Tags:
    Added json struct tags to the JWK and JWKS structs to ensure proper JSON serialization and deserialization. This improves compatibility with external APIs and ensures consistent JSON handling.

  2. Improved Error Messages:
    Standardized error messages to follow Go conventions by removing capitalization and punctuation. This aligns with Go's idiomatic error handling practices.

  3. Handled Unused Variables:
    Replaced unused variables with _ to explicitly indicate that they are intentionally ignored. This improves code readability and avoids linter warnings.

  4. Replaced Deprecated io/ioutil:
    Updated the code to use the io package instead of the deprecated io/ioutil package, as recommended in Go 1.16+. This ensures the codebase is up-to-date with modern Go practices.

  5. 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.

@fyvri fyvri requested a review from steiza as a code owner January 20, 2025 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant