Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

feat: Add skipping field tag #32

Merged
merged 2 commits into from
Aug 27, 2018
Merged

Conversation

rodnover55
Copy link
Contributor

Hello. Thank you for good library. But I don't see ability to skip some fields for faking data. This PR should be fix it.

@codecov
Copy link

codecov bot commented Aug 22, 2018

Codecov Report

Merging #32 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #32      +/-   ##
==========================================
+ Coverage   97.84%   97.86%   +0.01%     
==========================================
  Files           8        8              
  Lines         372      375       +3     
==========================================
+ Hits          364      367       +3     
  Misses          4        4              
  Partials        4        4
Impacted Files Coverage Δ
faker.go 95.37% <100%> (+0.08%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 25eb97b...9492f44. Read the comment docs.

faker.go Outdated
val, err := getValue(v.Field(i).Type())
if err != nil {
return reflect.Value{}, err
}
val = val.Convert(v.Field(i).Type())
v.Field(i).Set(val)
} else {
case "skip":
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for the PR.
We forgot to add this.
IMHO, I think it's better to use dash (-) instead of skip like what JSON tag's do if we want to ignore some field.

type Sample struct {
 ID string `json:"-"`

}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. :) smaller and simpler. Done.

Copy link
Owner

@bxcodec bxcodec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bxcodec bxcodec changed the title Add skipping field tag feat: Add skipping field tag Aug 24, 2018
@bxcodec bxcodec merged commit 0d9391e into bxcodec:master Aug 27, 2018
@bxcodec bxcodec mentioned this pull request Sep 18, 2018
@caldempsey
Copy link

Hi @bxcodec , this is insufficient when working with generated code (with generated struct tags). Could you add a method to ignore fields instead?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants