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

Feature Request: Enable Default Value Setting in Schemas via Unaltered Struct Field Names #116

Open
karimkhaleel opened this issue Nov 5, 2023 · 1 comment

Comments

@karimkhaleel
Copy link

Feature Request

Problem
When generating a schema, it would be beneficial to have the capability to set default values using an instance of the struct that is being converted into a schema.

Currently, this is challenging because the name specified in the struct tags may not correspond to the actual name of the struct field in the code, which makes it difficult to match the fields using their names.

Proposed Solution
To resolve this, we could include the original name of the struct field—unmodified by struct tags—in the schema. This would preserve the ability to match the fields based on their original names in the code, facilitating the setting of default values.

Alternatives Considered
An alternative method I have considered involves replacing the field name of the instantiated object with the name specified in the tag and using that for matching. However, this approach does not fully address the problem, as the name from the tag might be altered by a function like KeyNamer.

@stefanhaller
Copy link

Friendly ping; any thoughts about this? We need this functionality in lazygit, so we're currently forking to add it, but it would be nice if we didn't have to do that.

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

No branches or pull requests

2 participants