-
Notifications
You must be signed in to change notification settings - Fork 10
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 configuration options to NewFactValue #260
Conversation
8c1c86d
to
7e68407
Compare
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.
LGTM for the logic,
Just a couple of comments on the code style.
We can also use the functional options pattern, having in the end something more ideomatic like
NewFactValue(thingstocast, WithSnakeCase(), WithStringCasting())
or NewFactValue(thingstocast)
without any additional configuration, having the options as variadic arguments.
But this is up to you, we have two options for now, so as you wish.
The only things I request to change are in the comments.
Some examples of functional options pattern: https://charlesxu.io/go-opts/
if err != nil { | ||
return nil, err | ||
} | ||
if conf.SnakeCaseKeys { | ||
key = strcase.ToSnake(key) |
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 use a new scoped variable, not assigning to the key moving pointer in the for loop?
538d825
to
e044965
Compare
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.
LGTM!
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.
LGTM
stringConversion bool | ||
} | ||
|
||
type FactValuOption func(f *conf) |
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.
Did you mean FactValueOption
here?
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.
yes XD
381563a
to
52b9988
Compare
Create
NewFactValueWithConf
to enable configuration of theNewFactValue
function.Initially only
SnakeCaseKeys
andStringConversion
options are added