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
Slice: Add GroupBy func #10
Conversation
@duke-git please review |
Codecov Report
@@ Coverage Diff @@
## main #10 +/- ##
==========================================
+ Coverage 78.12% 78.21% +0.08%
==========================================
Files 22 22
Lines 1472 1487 +15
==========================================
+ Hits 1150 1163 +13
- Misses 215 216 +1
- Partials 107 108 +1
Continue to review full report at Codecov.
|
1379c85
to
67cfa47
Compare
Group by: split slice into two groups, applies on each slice element a predicate func to categorize this element. Changes * Add groub by func * Add test case for this func
@donutloop ,thanks, GroupBy func is helpful. |
@duke-git Almost all functions that currently use reflection to achieve reusability can be migrated to generics (a feature of 1.18). Can we open a branch v2 and start to migrate from reflection to generics soon? |
@donutloop. Thanks, good suggestion. It's necessary to replace reflection into generic. I do have the plan. The question is that generic support in Go 1.18 Beta which is a preview release, not production release. From my point of view, it's unstable for now. will it change or has minor adjustments in future version go?My suggestions are as follows: please review.
|
1.) I don't expect any major design changes because a beta API should already be in a frozen state. My recommendation, we can create a branch develop V2, and then start to develop the generic form of all affected functions. Let me know what you think |
@donutloop. Agree. I spent a couple of hours understand the go generics and try to rewrite some funcs (slice/slice.go, Map, Filter, ForEach). I find the code is concise and elegant after use generics, although generics syntax is a bit messy。I have checkout branch v2, we can migrate to generics in slice/slice.go step by step. How about it? |
Group by: split slice into two groups, applies on each slice element a
predicate func to categorize this element.
Changes