-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
multi: update build system to Go 1.23 #9512
base: master
Are you sure you want to change the base?
Conversation
Important Review skippedAuto reviews are limited to specific labels. 🏷️ Labels to auto review (1)
Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Nice, looking forward to using some of these new features 🎉
I found an example of using iterators in the spec: // fibo generates the Fibonacci sequence
fibo := func(yield func(x int) bool) {
f0, f1 := 0, 1
for yield(f0) {
f0, f1 = f1, f0+f1
}
}
// print the Fibonacci numbers below 1000:
for x := range fibo {
if x >= 1000 {
break
}
fmt.Printf("%d ", x)
}
// output: 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 Looks nice! |
1217876
to
acbafa7
Compare
This enables us to use the new language features that are a part of this release.
In this PR, we follow our practice of supporting the last 2 major Go versions by updating to Go 1.23. Go 1.24 was recently released
Notable Changes Language from Go 1.22
Go 1.23 introduced two major language enhancements:
Iterator Functions in for‑range Loops:
The “range” clause now accepts iterator functions. In other words, instead of being limited to slices, arrays, maps, channels, or strings, a for‑range loop can iterate over any function that conforms to one of these signatures:
func(func() bool)
func(func(K) bool)
func(func(K, V) bool)
This enables user‑defined iterators—think custom data streams or complex sequences—and has already been leveraged in new packages like
iter
, as well as enhanced support inslices
andmaps
.Preview Support for Generic Type Aliases:
Go 1.23 offers experimental support for defining generic type aliases. By building the toolchain with the environment flag
you can write type aliases that are generic. (Note that using these generic alias types across package boundaries is not yet supported.)
What Go 1.22 Users Should Know
Module Versioning Matters:
These language changes only take effect when your module’s
go.mod
declares a Go version of 1.23 or later. If you’re still using Go 1.22 (or a module that specifies an older version), your code will continue to behave as before.Iterator Functions May Change Iteration Style:
If you adopt the new iterator function style, your loops may look and behave differently. Review any custom iteration logic and test thoroughly when migrating.
Generic Type Aliases Are Experimental:
Since support for generic type aliases is in preview, expect that some details might evolve in future releases. Use them with caution, especially in public APIs or across packages.
While Go 1.23 also brings improvements in tooling, runtime performance, and standard library enhancements, these two language features are the standout changes that directly affect how you write Go code.