actions-oidc-gateway-example icon indicating copy to clipboard operation
actions-oidc-gateway-example copied to clipboard

refactor: add json tags and improve error message

Open fyvri opened this issue 10 months ago • 0 comments

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 avatar Jan 20 '25 17:01 fyvri