This site is being rebuilt and some pages are out of date. For current details, write to [email protected]. This notice goes away when the rebuild is done.

No analytics unless you allow it, no tracking. This site keeps in your browser the language you pick, the theme, its colour, which site you chose, the currency on the pricing page and that you closed this notice; signing in adds session cookies. The legal page has the details.

Sign in

Radar · Go · #001 · Week 39 · Sep 21 – 27, 2026

testing: add goroutine labels to tests

Nice to knowtooling

What changed
Accepted: the testing package will label the goroutine running every test, benchmark, example and fuzz test with test.name (the function's name, such as TestParse) and test.iter (which run of it this is, counting from 0 up to -test.count).
Production impact
The source does not say.
Try it
Until it ships, set labels yourself with pprof.Do from runtime/pprof; a CPU profile then shows which labels each sample ran under.
Source
github.com/golang/go/issues/75047

Understand it, then run it

A goroutine can carry labels: small key and value pairs, such as test.name=TestParse. They cost nothing to read your code with, but profiles record them, so when you look at where a program spends its time you can see which piece of work each part belongs to.

The accepted proposal has the testing package set two labels on its own whenever it runs a test, benchmark, example or fuzz test: the test's name and which run of it this is. You will not need to change a single test to get them.

Run it now

Todaygo
package main

import (
	"context"
	"fmt"
	"runtime/pprof"
)

// Goroutine labels already exist: pprof.Do sets them, and CPU profiles record
// every sample with the labels of the goroutine that took it. The accepted
// proposal has the testing package set two of them for you, test.name and
// test.iter. This sets the same two by hand and reads them back.
func main() {
	labels := pprof.Labels("test.name", "TestParse", "test.iter", "0")
	pprof.Do(context.Background(), labels, func(ctx context.Context) {
		// Everything run here, and every goroutine started from here,
		// carries the labels in a profile.
		pprof.ForLabels(ctx, func(key, value string) bool {
			fmt.Printf("%s=%s\n", key, value)
			return true
		})
	})
}

What it printed when we ran it on Go 1.27.1

test.iter=0
test.name=TestParse

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.

Written by gpt-oss-120b from the linked source · claims checked against the sources · human-reviewed