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

Allow structs without public fields to implement Setter #83

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

Conversation

urso
Copy link

@urso urso commented Dec 22, 2021

If a struct does not provide a public field that might be set by cleanenv, then the struct was ignored. This did make it impossible to implement a custom struct with SetValue.

The change checks if a field implements SetValue. If SetValue is implemented we stop recursing into the type to looks for other fields that might be populated via cleanenv.

The new example test used to fail because SetValue was not called.

If a struct does not provide a public field that might be set by
cleanenv, then the struct was ignored. This did make it impossible to
implement a custom struct with SetValue.

The change checks if a field implements SetValue. If SetValue is
implemented we stop recursing into the type to looks for other fields
that might be populated via cleanenv.
@awendland
Copy link

awendland commented Feb 17, 2023

I also needed this functionality. My goals was to support validation of custom types during config loading. Before finding this PR, my forked version implements the solution the same way.

@ilyakaznacheev first off, thank you for creating this library! It's been very helpful. Secondly, are there any blockers I could help with to get this merged?

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.

None yet

2 participants