Archive · Week 34 · Aug 18 – 24, 2025from 2 items
This week the Go team accepted a proposal that adds a convenient iterator for package import graphs, and the Go blog announced that the default value of GOMAXPROCS will be tuned for container environments in Go 1.25.
Worth knowingtooling
x/tools/go/packages: add Postorder iterator
- What changed
- The proposal adds a
Postorderfunction that returns aniter.Seq[*Package]over packages in dependencies‑first order. - Production impact
- The source does not say.
- Try it
- In a Go program that imports
golang.org/x/tools/go/packages, callpackages.Postorder(pkgs)to iterate over loaded packages instead of usingpackages.Visit. - Source
- github.com/golang/go/issues/74875
Exercise
Write a small program that prints the current value of GOMAXPROCS and then sets it to the maximum number of CPUs available, printing the new value.
package main
import (
"fmt"
"runtime"
)
func main() {
// TODO: print current GOMAXPROCS
// TODO: set GOMAXPROCS to the number of CPUs
// TODO: print the new GOMAXPROCS
}
Show a solution
package main
import (
"fmt"
"runtime"
)
func main() {
fmt.Println("current GOMAXPROCS:", runtime.GOMAXPROCS(0))
runtime.GOMAXPROCS(runtime.NumCPU())
fmt.Println("new GOMAXPROCS:", runtime.GOMAXPROCS(0))
}
What it printed when we ran it on Go 1.27.1
current GOMAXPROCS: 2 new GOMAXPROCS: 2
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
This week the Go team added a new helper to the packages tool that lets you walk the import graph in a clean, dependencies‑first order. Instead of the older Visit function you can now call Postorder and get a simple iterator. It’s a small change, but it makes scripts that analyse packages a little easier to write. In the runtime area, the team announced that the default GOMAXPROCS value will be tuned for containers in Go 1.25. That means your programs will automatically use a more appropriate number of threads when they run inside a container, without you having to change any code. Both updates are worth knowing for anyone who builds tools that work with Go packages or runs Go services in containerised environments.
Written by gpt-oss-20b · claims checked against the sources · archive, not individually reviewed