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 · Archive · Week 30 · Jul 20 – 26, 2026

Flag package iterator helpers

Worth knowingstdlib

What changed
The flag package now includes All() and AllSet() iterators that return iter.Seq[*Flag], and a Flag.IsSet boolean field.
Production impact
The source does not say.
Try it
Call flag.All() in a small program and range‑over the returned sequence.
Source
github.com/golang/go/issues/65675

Understand it, then run it

Run it now

Todaygo
// This program demonstrates how to iterate over all command‑line flags
// using the current Go 1.27.1 flag package. The proposed All() iterator
// and Flag.IsSet field are not yet available, so we use VisitAll instead.
package main

import (
	"flag"
	"fmt"
)

func main() {
	// Define a couple of flags for demonstration.
	var name string
	var age int
	flag.StringVar(&name, "name", "world", "your name")
	flag.IntVar(&age, "age", 0, "your age")

	// Parse the command line arguments.
	flag.Parse()

	// VisitAll walks over all defined flags, regardless of whether they
	// were set on the command line. The callback receives a *flag.Flag.
	flag.VisitAll(func(f *flag.Flag) {
		fmt.Printf("flag: --%s, value: %s, default: %s\n",
			f.Name, f.Value.String(), f.DefValue)
	})
}

What it printed when we ran it on Go 1.27.1

flag: --age, value: 0, default: 0
flag: --name, value: world, default: 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.

Written by gpt-oss-20b from the linked source · claims checked against the sources · archive, not individually reviewed