-
Notifications
You must be signed in to change notification settings - Fork 113
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
Add support for named parameters #227
Conversation
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.
@ajzo90 Thanks for this PR. Please see my comments.
// override with ordinal if set | ||
for _, v := range args { | ||
if v.Ordinal == i+1 { | ||
arg = v | ||
} | ||
} | ||
|
||
// override with name if set | ||
for _, v := range args { | ||
if v.Name == paramName { | ||
arg = v | ||
} | ||
} |
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.
Can we merge these two loops?
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.
It is in 3 passes to set different priorities. For example in case the client code or a wrapper library is setting/generating NamedValues
with both a Name
and an Ordinal
as a fallback mechanism.
This PR adds support for named parameters.
It tries to keeps old behaviour intact, but introduces some vague interpretation since it can mix named and non-named parameters. Possibly a better alternative is to check whether named or positional parameters are used and do strict validation.