-
Notifications
You must be signed in to change notification settings - Fork 98
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
fieldpath: add DeleteField
function to delete elements from Paved
#344
Conversation
Signed-off-by: Muvaffak Onus <me@muvaf.com>
DeleteField
function to delete elements from Paved
…nables unexpected linters Signed-off-by: Muvaffak Onus <me@muvaf.com>
I've noticed that two cases weren't handled and added them:
Added unit tests for both but couldn't reduce cyclomatic complexity without breaking @turkenh could you take another look? |
…d it should be able to delete a top-level field Signed-off-by: Muvaffak Onus <me@muvaf.com>
// on that index is removed and the next ones are pulled | ||
// back. If it is a field on a map, the field is | ||
// removed from the map. | ||
func (p *Paved) DeleteField(path string) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, I could be convinced to rename this to DeleteKey
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Key
wouldn't be a good fit if array. What about DeleteItem
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would simply Delete
work? As in paved.Delete
to delete whatever is at the supplied field path?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@turkenh I feel like Field
is more familiar than Item
in this context for the users of fieldpath.
@negz I think it'd read nice if we had Get
/Set
/Delete
but given that there is GetValue
/SetValue
, paved.Delete
feels a bit off without a noun that says what you're deleting.
Thanks for the suggestions folks!
Description of your changes
Introduces
DeleteField
to delete a field from the given object.Fixes #343
I have:
make reviewable test
to ensure this PR is ready for review.How has this code been tested
Unit tests with 100% coverage.