-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Use custom type and constants to hold available order by options #2572
Use custom type and constants to hold available order by options #2572
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2572 +/- ##
==========================================
+ Coverage 27.32% 27.33% +<.01%
==========================================
Files 86 86
Lines 17135 17137 +2
==========================================
+ Hits 4682 4684 +2
Misses 11775 11775
Partials 678 678
Continue to review full report at Codecov.
|
LGTM |
LGTM |
//SearchOrderBy is used to sort the result | ||
type SearchOrderBy string | ||
|
||
func (s SearchOrderBy) String() string { |
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.
Actually just reviewed it again and does that function is needed? Why not to use string(x) where needed?
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.
Because you don't need to care what type SearchOrderBy is (try to think about it like you don't know that it's only string) and this way it implements Stringer
interface. string(x)
will not work without other changes if you change SearchOrderBy to int for example. Changing constants should not affect other code.
Extracted from #2371. Replace strings for constants.