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

Refactor the match.CheckOff API to use functional options #711

Merged
merged 1 commit into from
Feb 16, 2024

Conversation

kegsay
Copy link
Member

@kegsay kegsay commented Feb 16, 2024

This means you don't need to tack on , nil all the time, and can optionally specify when you want to allow unwanted items, obviating the need for JSONCheckOffAllowUnwanted. This composes better and supports adding additional functionality e.g allowing duplicate items.

This means you don't need to tack on `, nil` all the time, and can
optionally specify when you want to allow unwanted items, obviating
the need for `JSONCheckOffAllowUnwanted`. This composes better and
supports adding additional functionality e.g allowing duplicate items.
@kegsay kegsay requested review from a team as code owners February 16, 2024 17:02
Copy link
Contributor

@devonh devonh left a comment

Choose a reason for hiding this comment

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

Everything checks out. Definitely makes the api a little easier to understand.

if item == nil {
err = fmt.Errorf("JSONCheckOff(%s): mapper function mapped %v to nil", wantKey, itemRes.Raw)
return false
var item interface{} = itemRes
Copy link
Contributor

Choose a reason for hiding this comment

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

Nifty use of interface here

@kegsay kegsay merged commit 503bf6e into main Feb 16, 2024
4 checks passed
@kegsay kegsay deleted the kegan/check-off branch February 16, 2024 17:26
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.

2 participants