Go 1.26 just dropped :) and there’s some interesting stuff in this release. Here are a few that you will certainly find useful.
newcan now take an expression as the initial value
We can now pass an expression directly to new to set the initial value. This is nice when dealing with serialization libraries like encoding/json or protobufs, where pointers are often used to represent optional fields.
Instead of writing helper functions or doing multi-line setup, we can now just write something like new(yearsSince(born)) [example taken from the release notes as is] and be done with it. Much cleaner and easier to read.
- The Green Tea garbage collector is the default
Second, the Green Tea garbage collector, which was experimental in Go 1.25, is now enabled by default in Go 1.26. Some key highlights of this GC -
The Green Tea garbage collector is now enabled by default. Real-world programs that heavily use the GC should see a 10-40% reduction in garbage collection overhead. This GC also leverages vector instructions for scanning small objects, giving about a 10% benefit out of the box.
- Cgo calls have 30% less runtime overhead. Sweet.
If your Go code makes heavy use of cgo (language bindings to underlying C libraries like ImageMagick and RocksDB, etc.), this is a direct performance win with zero code changes.
By the way, there is also an experimental goroutine leak profile that can identify goroutines blocked on channels, mutexes, or condition variables that are no longer reachable. This comes in pretty handy when debugging straggler issues caused by stuck goroutines.
There is more in the release notes, but these were the four changes I found interesting. The full release notes are linked below if you want to dig in.