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

feat: implement map to retain original struct field names in schema #117

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

karimkhaleel
Copy link

Description:
This pull request introduces a new enhancement that addresses the feature request outlined in #116. A public map[string]string has been added to the Schema struct which serves to preserve the original names of struct fields as reflected before any modifications by struct tags or KeyNamer.

The primary purpose of this new field is to provide an accessible means through the schema object, enabling the matching of an instantiated struct's fields with the corresponding schema definitions during a post-processing phase.

Usage Example:
An envisioned application of this feature, pending its acceptance and merge, can be previewed in the lazygit project's open pull request, specifically at generate.go#L43.

With this addition, developers can now directly utilize the unaltered struct field names from the schema object, simplifying and streamlining the schema manipulation process.

@samlown samlown added the needs tests Not enough tests for this to be accepted label Feb 19, 2024
Introduces a mapping mechanism within the `Schema` type to
store the original reflected struct field names before any
modifications.
@karimkhaleel karimkhaleel force-pushed the original-names-mapping branch from 5eb3a54 to 00bb22f Compare March 7, 2024 19:40
@karimkhaleel
Copy link
Author

Added a test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs tests Not enough tests for this to be accepted
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants