Archive · Week 9 · Feb 24 – Mar 2, 2025from 7 items
The Go team accepted several proposals that refine language tooling, runtime behaviour, and standard library ergonomics. The changes touch Unicode handling in the regexp package, runtime cleanup semantics, HTTP content‑negotiation, HTTP/2 extended CONNECT support, and the `go` command’s work‑module package pattern. A new blog post highlights the map performance boost in Go 1.24.
Worth knowingstdlib
regexp/syntax: recognize Unicode category aliases
- What changed
- The regexp package now recognises Unicode category aliases, the pseudo‑categories Any, Assigned, and ASCII, and accepts case‑insensitive names such as
\p{ascii}. - Production impact
- The source does not say.
- Try it
- Run
go test -run TestUnicodeAliasesin the regexp package. - Source
- github.com/golang/go/issues/70781
Explain it
Understand it, then run it
The regexp package in Go can match Unicode characters using the \p{…} syntax. Before this change, it only understood the short two‑letter codes like \p{L} for letters. It did not recognize longer names such as \p{Letter} or the special groups \p{Any}, \p{Assigned}, and \p{ASCII}. The new change adds support for those longer names and for the pseudo‑categories. It also makes the names case‑insensitive, so \p{ascii} works the same as \p{ASCII}. With this update, patterns that use the full Unicode names will work correctly, making the package more aligned with the Unicode standard and easier to use in real‑world text processing.
Worth knowingstdlib
unicode: add CategoryAliases, LC, Cn
- What changed
- A new
CategoryAliasesmap, and theLCandCnrange tables were added to the unicode package. - Production impact
- The source does not say.
- Try it
- Use
unicode.CategoryAliases["Letter"]in a small program. - Source
- github.com/golang/go/issues/70780
Explain it
Understand it, then run it
The Unicode package in Go keeps tables that describe what each character is. A long time ago the tables did not include a small map that tells the package which short names mean which long names. For example, the short name L means “Letter”, but the long name Letter was not linked. The change adds a map called CategoryAliases that maps names like Letter to the short form L. It also adds two new tables, LC for “Cased Letter” and Cn for “Unassigned”, so that the package can refer to them directly.
Worth knowingruntime
runtime: allow cleanups to run concurrently
- What changed
- Documentation for
runtime.AddCleanupwas updated to state that cleanups run concurrently with user goroutines and with each other. - Production impact
- The source does not say.
- Try it
- Call
runtime.AddCleanupfrom multiple goroutines and observe concurrent execution. - Source
- github.com/golang/go/issues/71825
Explain it
Understand it, then run it
The runtime.AddCleanup function lets a program register a function that will run when the program exits. Until recently the documentation said that all cleanup functions run in a single goroutine, one after another. The change removes that wording and says that cleanups now run concurrently with each other and with user goroutines. This means a long‑running cleanup will no longer block other cleanups or the rest of the program.
Worth knowingtooling
cmd/go: add `work` package pattern matching all packages in work modules
- What changed
- A new meta‑pattern
workwas added to thegocommand to match all packages in work modules. - Production impact
- The source does not say.
- Try it
- Run
go test work/...in a workspace. - Source
- github.com/golang/go/issues/71294
Explain it
Understand it, then run it
The go command can take *package patterns* to tell it which packages to build, test, or install. Existing patterns include all, std, cmd, and tool. A new pattern called work was added to match every package that belongs to the current work (or workspace) modules. This lets you run a single command to build or test all of those packages, instead of having to list each one or use a long relative path pattern.
Nice to knowecosystem
Faster Go maps with Swiss Tables
- What changed
- Go 1.24 introduces a new map implementation that improves performance.
- Production impact
- The source does not say.
- Try it
- Benchmark a map in Go 1.24 versus an older version.
- Source
- go.dev/blog/swisstable
Explain it and run it
Understand it, then run it
Run it now
// This program demonstrates the new Swiss Table map implementation in Go 1.24.
// It creates a map, inserts many entries, and measures lookup speed.
// The code runs unchanged in Go 1.27.1, which already includes the Swiss Tables.
package main
import (
"fmt"
"math/rand"
"time"
)
func main() {
const n = 1_000_000
m := make(map[int]int, n)
// Fill the map with random keys.
start := time.Now()
for i := 0; i < n; i++ {
m[rand.Int()] = i
}
fmt.Printf("Insertion time: %v\n", time.Since(start))
// Look up all keys to exercise the new map internals.
start = time.Now()
sum := 0
for k := range m {
sum += m[k]
}
fmt.Printf("Lookup time: %v, sum: %d\n", time.Since(start), sum)
}
What it printed when we ran it on Go 1.27.1
Insertion time: 191.088174ms Lookup time: 23.684702ms, sum: 499999500000
Run sends this program (for Solidity, the contract and its tests) to our own sandbox, where it is compiled and run once, with no network, and what it printed or the test report comes back here. Nothing is kept. Runs are counted per visitor for the day so everyone gets a turn; the details are on the legal page.
Exercise
Write a small program that uses the new NegotiateContent function to choose the best content type from a list of offers based on a given Accept header.
The 60-second version
Hello, and welcome to this week’s Go Radar. This week the Go team rolled out a handful of refinements that make the language and its libraries a bit more expressive and a touch more efficient. First, the regexp package now understands Unicode category aliases, so patterns like `\p{Letter}` or `\p{ascii}` work out of the box. The unicode package itself received a small but useful table of aliases and two new range tables, LC and Cn, to aid in character classification. In the runtime, clean‑up functions are no longer forced to run one after another; they now execute concurrently, which can help avoid long‑running cleanup code from blocking other work. The net/http package gained a new helper, NegotiateContent, that implements RFC 9110 content‑type negotiation, making it easier to serve the best representation to clients. It also added a knob to enable HTTP/2’s extended CONNECT protocol, giving server developers finer control over protocol advertising. On the tooling side, the go command now supports a `work` pattern that matches all packages in a workspace, simplifying build and test commands. Finally, a blog post highlighted the new Swiss‑Table map implementation that brings a measurable performance boost to Go maps in the upcoming 1.24 release. Those are the highlights for this week—thanks to the Go team for their continued work on improving the ecosystem.
Written by gpt-oss-20b · claims checked against the sources · archive, not individually reviewed