Archive · Week 39 · Sep 22 – 28, 2025from 6 items
The Go team delivered a handful of proposals that broaden the language’s tooling and runtime ergonomics. A new diagnostic tool, Flight Recorder, arrives in Go 1.25, while several analysis passes are moved into the core `x/tools/go/analysis` package to make them available to `go fix`. In the standard library, helpers for CPU affinity and reflection iterators are added, and the `errors` package gains a type‑parameterized `AsType` helper.
Worth knowingtooling
x/tools/go/analysis/passes/modernize: publish
- What changed
- The modernize analyzer suite is moved to
x/tools/go/analysis/passes/modernizeand can now be used bygo fix. - Production impact
- The source does not say.
- Try it
- Run
go fix -r modernizeon a repository that contains modernize‑eligible code. - Source
- github.com/golang/go/issues/75266
Explain it
Understand it, then run it
The Go team moved a set of static‑analysis tools that suggest modern language or library features into a new package called x/tools/go/analysis/passes/modernize. These tools were previously hidden inside the editor server gopls. Now they are part of the public analysis framework and can be run by the go fix command. The change does not alter any language syntax; it only changes where the code lives and how it can be invoked.
Worth knowingtooling
x/tools/go/analysis/passes/inline: publish //go:fix inline analyzer
- What changed
- The inline analyzer is moved to
x/tools/go/analysis/passes/inlineand can now be used bygo fix. - Production impact
- The source does not say.
- Try it
- Run
go fix -r inlineon a package that contains//go:fix inlinedirectives. - Source
- github.com/golang/go/issues/75267
Explain it and run it
Understand it, then run it
Run it now
// This program demonstrates a function annotated with //go:fix inline.
// In a Go 1.27.1 environment, running `go fix -fix=inline` would replace
// the call to add(2, 3) with the literal result 5, eliminating the function call.
package main
import "fmt"
//go:fix inline
func add(a, b int) int {
return a + b
}
func main() {
// The call below is a candidate for inlining by the inline analyzer.
result := add(2, 3)
fmt.Println(result) // prints 5
}
What it printed when we ran it on Go 1.27.1
5
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
Task Write a program that takes a string and a prefix, removes the prefix if it is present, and prints the remaining string. Use the standard library’s strings.CutPrefix function (introduced in Go 1.22) to perform the removal.
package main
import (
"fmt"
"strings"
)
func main() {
// Replace the following line with your own implementation.
// The program should read a string and a prefix, cut the prefix
// if present, and print the result.
}
Show a solution
package main
import (
"fmt"
"strings"
)
func main() {
// Example input
s := "hello, world"
prefix := "hello, "
// Cut the prefix if it is present
if strings.HasPrefix(s, prefix) {
s = strings.TrimPrefix(s, prefix)
}
fmt.Println(s) // Output: world
}
What it printed when we ran it on Go 1.27.1
world
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.
The 60-second version
Hello, I’m here to share a few updates from the Go team this week. First, Go 1.25 brings a new diagnostic tool called Flight Recorder, giving you a way to capture and analyze program execution. In tooling, the modernize and inline analyzers have been moved into the core analysis package, so you can now use them directly with `go fix`. On the standard library side, a handy `Fill` method was added to `unix.CPUSet`, making it simple to reset CPU affinity. The `reflect` package now offers iterator versions of its field and method APIs, and the `errors` package introduces a type‑parameterized `AsType` helper for cleaner error handling. These changes aim to make Go’s tooling and runtime more expressive and easier to work with.
Written by gpt-oss-20b · claims checked against the sources · archive, not individually reviewed