cleanenv icon indicating copy to clipboard operation
cleanenv copied to clipboard

Custom functions are not running for values from files

Open amirylm opened this issue 3 years ago • 3 comments

I've noticed that when reading a config file with a field that is not available in env, its custom function won't run.

The reason seems to be that for these kind of fields, parseValue won't be called and therefore the corresponding custom function.

Custom functions runs only if the field was provided as an env argument or with a zero'ed value:

  • https://github.com/ilyakaznacheev/cleanenv/blob/ce3ee7fb74f018e1dc0f302520bba3c44ce2f786/cleanenv.go#L309
  • https://github.com/ilyakaznacheev/cleanenv/blob/ce3ee7fb74f018e1dc0f302520bba3c44ce2f786/cleanenv.go#L321

amirylm avatar May 23 '21 16:05 amirylm

Thanks, marked to be fixed.

Feel free to send a PR with a fix if you have ideas on how to fix that! I had huge issues with free time last months, so not sure when I will fix that by myself.

ilyakaznacheev avatar Jul 22 '21 21:07 ilyakaznacheev

👋🏻 @ilyakaznacheev I would love to take a look at this. Could you assign this to me? Thanks!

pansachin avatar Oct 05 '22 14:10 pansachin

@pansachin sure, thanks

ilyakaznacheev avatar Nov 08 '22 07:11 ilyakaznacheev