Go 1.23.0 has been released!

August 15, 2024

I missed the last couple of days. Oops! It’s a busy time here, as I’m preparing for an international move, and balancing a new business venture I’m working on.

But I’m back today!

The big news in the Go world is that on Tuesday, Go 1.23.0 was released!

What this means for us, as we venture through the Go spec, is that there are new changes to the spec we need to talk about!

And there’s one big change to the Go spec this time around: The new “range-over-func” feature. From the release notes:

Go 1.23 makes the (Go 1.22) “range-over-func” experiment a part of the language. The “range” clause in a “for-range” loop now accepts iterator functions of the following types

func(func() bool)
func(func(K) bool)
func(func(K, V) bool)

as range expressions. Calls of the iterator argument function produce the iteration values for the “for-range” loop. For details see the iter package documentation and the language spec. For motivation see the 2022 “range-over-func” discussion.

We’ve already gone over the relevant section of the spec, just a few weeks ago, when we talked about the different for range constructs. But now there’s a new one. So that’s what I’ll be going over next.

Here’s the added text, as a preview:

  1. For a function f, the iteration proceeds by calling f with a new, synthesized yield function as its argument. If yield is called before f returns, the arguments to yield become the iteration values for executing the loop body once. After each successive loop iteration, yield returns true and may be called again to continue the loop. As long as the loop body does not terminate, the “range” clause will continue to generate iteration values this way for each yield call until f returns. If the loop body terminates (such as by a break statement), yield returns false and must not be called again.

That’s pretty much it. One paragraph (and some examples we’ll see later).

But there’s a lot to unpack there, so we’ll do that in the coming days.

If you’re interested in a more practical, and less theoretical, discussion of this feature, check out my recent blog post on the topic.


Share this

Direct to your inbox, daily. I respect your privacy .

Unsure? Browse the archive .

Get daily content like this in your inbox!

Subscribe