gorilla / schema

Package gorilla/schema fills a struct with form values.
https://gorilla.github.io
BSD 3-Clause "New" or "Revised" License
1.38k stars 229 forks source link

Add default tag #183

Closed zak905 closed 8 months ago

zak905 commented 3 years ago

Summary of Changes

this is the implementation for the functionality described in #182

  1. add support for an optional default tag to allow setting values when decoding in case no value is provided
  2. limiting the default tag scope to only primitive types and their pointers as well
stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it hasn't seen a recent update. It'll be automatically closed in a few days.

zak905 commented 2 years ago

Hello Gorilla Maintainers,

@kisielk @elithrar @moraes @zeebo

any chance getting this reviewed or at least getting a feedback ? I am already using this directly from my own fork, works great so far

jaitaiwan commented 9 months ago

I took a quick glance over this, nothing stands out to me. @zak905 I know it's been awhile, are you willing to update the PR with the latest base branch?

zak905 commented 9 months ago

@jaitaiwan done. thanks for looking into it. I am glad to see the project active again

codecov[bot] commented 9 months ago

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (4890efc) 83.23% compared to head (7807359) 86.59%.

Files Patch % Lines
decoder.go 92.45% 3 Missing and 1 partial :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #183 +/- ## ========================================== + Coverage 83.23% 86.59% +3.35% ========================================== Files 4 4 Lines 710 843 +133 ========================================== + Hits 591 730 +139 + Misses 103 96 -7 - Partials 16 17 +1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

AlexVulaj commented 9 months ago

Thanks so much for the contribution @zak905 - I hate to ask any more of you when this has already been in progress for so long, but is there any chance the tests could be updated to meet our coverage standards? I'll make a special note to watch out for this PR to get it in asap.

zak905 commented 9 months ago

Sure thing, I will look into it asap. Thanks.

zak905 commented 9 months ago

@AlexVulaj thanks again for looking into this. I have added more testing to cover the unreached code, it should be ok now hopefully

AlexVulaj commented 9 months ago

@jaitaiwan I'm good with this, wanna give it a quick last glance and merge?

jaitaiwan commented 8 months ago

All finished @zak905 , appreciate the contribution.

zak905 commented 8 months ago

Welcome. Thanks @AlexVulaj and @jaitaiwan. I have to admit that I thought that this will never get merged, especially after the Gorilla project got archived :) so I would say this a great twist. Hopefully this will make setting default values trivial - I am hoping to see also some similar functionality in the standard golang json package someday.

By the way, do you think it's worth adding a README section about the default tag option ?

jaitaiwan commented 8 months ago

Definitely, if you’re happy to make a contribution we’ll endeavour to look asap.

zak905 commented 8 months ago

thanks. Read me updated at: https://github.com/gorilla/schema/pull/209

zak905 commented 7 months ago

@jaitaiwan is it possible to create a release for this changeset (and other changes that occured since v1.2.1) ?

jaitaiwan commented 7 months ago

Definitely possible @zak905

zak905 commented 7 months ago

awesome thanks