-
Notifications
You must be signed in to change notification settings - Fork 19
nit(attribute-validation): Using switch instead of multiple if checks. #341
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
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.
A clarification
pkg/event/factory.go
Outdated
} | ||
if _, ok := value.(bool); ok { | ||
switch value.(type) { | ||
case string, float64, int, bool: |
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.
Does this change work for float32, int8, which should be accepted?
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.
https://go.dev/tour/basics/11
should give all types?
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
wondering what's wrong with the original if-based one. It'll cover all types.
i tried the new tests for both new and previous code, behaviour was the same. We would've required |
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
Fixes:
Tests:
Jira ticket:
https://optimizely.atlassian.net/browse/OASIS-8593