-
Notifications
You must be signed in to change notification settings - Fork 61
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
Upgrade go-functional to v2 #3392
Upgrade go-functional to v2 #3392
Conversation
I'd also consider adding |
Note that merging this would break #3383 - which is why I wanted to make you aware of it now. |
Thanks, Tom! We wanted to go straight to go-functional v2 but we decided not to as golang 1.23 is not ofcially released yet. go-functional is quite a cool library, it has been on my radar for a while and finally we got to it. I was going to give you a heads up that you have a new user but obviously you found that out yourself :) |
FWIW, I have reported the issue with staticcheck: dominikh/go-tools#1578 |
6977ae6
to
8bfc20f
Compare
@danail-branekov I've updated the PR to include the recent usages of go-functional. In addition, I noticed use the the |
6e3b9e1
to
ab01a80
Compare
Thanks, Tom, this is awesome - this would save us quite some time once we want to go for go-functional v2 We are currently unable to merge that though until we bump to golang 1.23 |
Just FYI based on your feedback on another thread for collecting iterators that yield errors and values - in
|
ab01a80
to
2334a71
Compare
Hey @BooleanCat I saw that golang 1.23 is now out and I was eager to merge your pr. Unfortunately, latest staticcheck seems to have issues with golang 1.23 (even though it is supposed to support it) and that is failing our I have rebased your changes against latest main, resolved conflicts and replaced recently introduced references to go-functional v1 with v2. I have pushed that to a new branch, feel free to update your PR branch accordingly in order to get all the credits :) |
2334a71
to
498fb93
Compare
Done and upgraded to beta.6 |
Almost there, @BooleanCat With yesterdays release of staticcheck our linters are now happy. I have resolved the conflicts with the current main and fixed a linter issue by ammending the Could you pick up those changes in your branch so that I can merge the PR? |
498fb93
to
181c1ae
Compare
Done |
A couple of api tests are failing as the result of collecting an empty iterator is |
By switching to go-functional v2 and adopting golang 1.23 iterators, collecting an empty iterator results into `nil` rather than en empty slice. This makes no difference to Korifi, therefore this commit removes explicit checks for empty non-nil slices in tests
OK, here is the commit that fixes the failures: d3ac8fb @BooleanCat could you pick that up as well? Hopefully, this is goingto be the last iteration |
Head branch was pushed to by a user without write access
181c1ae
to
a4a2001
Compare
All done |
Is there a related GitHub Issue?
N/A.
What is this change about?
You're currently using version 1 of go-functional which I'm no longer maintaining. This upgrades go-functional to v2 and uses Go 1.23's native
iter.Seq
functionality for iterators - making all iterators in this library first-class iterators supported by the language.There's two main packages of interest:
it
contains the iterators you are already usingitx
contains helpers to support iterator chainingUnfortunately it's not possible to chain
Map
because of a limitation with Go's type system (you can't declare new generic arguments on a method not present on its type). But this was also a limitation of version 1 of go functional too.Native Go iterators can be "lifted" to their chainable type by using
itx.From(iterator)
.If this eventually gets merged once you use Go 1.23 I'd be happy to comb through the code and find places where go-functional simplifies the codebase.
Does this PR introduce a breaking change?
Yes - you'll need to use Go 1.23. I notice you're using rc2 in your container images but 1.23 is not declared as the minimum version in the
go.mod
yet.Acceptance Steps
No functional change.
Tag your pair, your PM, and/or team
N/A.