all: upgrade go directive to at least 1.25.0 [generated]

By now Go 1.26.0 has been released, and Go 1.24 is no longer supported
per the Go Release Policy (see https://go.dev/doc/devel/release#policy).

For golang/go#69095.

[git-generate]
(cd . && go get go@1.25.0 && go mod tidy && go fix ./... && go mod edit -toolchain=none)

Change-Id: I184fe7b71ad5ddf5259be1f75d0689a0925b8e65
Reviewed-on: https://go-review.googlesource.com/c/benchmarks/+/744120
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Gopher Robot <gobot@golang.org>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
diff --git a/cmd/bent/bent.go b/cmd/bent/bent.go
index c811e21..8d3b1b4 100644
--- a/cmd/bent/bent.go
+++ b/cmd/bent/bent.go
@@ -1209,23 +1209,24 @@
 
 // asCommandLine renders cmd as something that could be copy-and-pasted into a command line
 func asCommandLine(cwd string, cmd *exec.Cmd) string {
-	s := "("
+	var s strings.Builder
+	s.WriteString("(")
 	if cmd.Dir != "" && cmd.Dir != cwd {
-		s += "cd" + escape(cmd.Dir) + ";"
+		s.WriteString("cd" + escape(cmd.Dir) + ";")
 	}
 	for _, e := range cmd.Env {
 		if !strings.HasPrefix(e, "PATH=") &&
 			!strings.HasPrefix(e, "HOME=") &&
 			!strings.HasPrefix(e, "USER=") &&
 			!strings.HasPrefix(e, "SHELL=") {
-			s += escape(e)
+			s.WriteString(escape(e))
 		}
 	}
 	for _, a := range cmd.Args {
-		s += escape(a)
+		s.WriteString(escape(a))
 	}
-	s += " )"
-	return s
+	s.WriteString(" )")
+	return s.String()
 }
 
 // checkAndSetUpFileSystem does a number of tasks to ensure that the tests will
@@ -1441,8 +1442,8 @@
 		return nil
 	}
 	m := make(map[string]bool)
-	ss := strings.Split(s, ",")
-	for _, sss := range ss {
+	ss := strings.SplitSeq(s, ",")
+	for sss := range ss {
 		m[sss] = true
 	}
 	return m
diff --git a/driver/driver.go b/driver/driver.go
index e1781f0..5d399f0 100644
--- a/driver/driver.go
+++ b/driver/driver.go
@@ -84,11 +84,9 @@
 }
 
 func setupWatchdog() {
-	t := *benchTime
-	// Be somewhat conservative, and build benchmark does not care about benchTime.
-	if t < time.Minute {
-		t = time.Minute
-	}
+	t := max(
+		// Be somewhat conservative, and build benchmark does not care about benchTime.
+		*benchTime, time.Minute)
 	t *= time.Duration(*benchNum)
 	t *= 2 // to account for iteration number auto-tuning
 	if *flake > 0 {
@@ -280,7 +278,7 @@
 	numProcs := P * runtime.GOMAXPROCS(0)
 	var wg sync.WaitGroup
 	wg.Add(numProcs)
-	for p := 0; p < numProcs; p++ {
+	for range numProcs {
 		go func() {
 			defer wg.Done()
 			for int64(atomic.AddUint64(&N, ^uint64(0))) >= 0 {
diff --git a/garbage/garbage.go b/garbage/garbage.go
index 1c26aa7..fe185b6 100644
--- a/garbage/garbage.go
+++ b/garbage/garbage.go
@@ -37,7 +37,7 @@
 		avail := (driver.BenchMem() << 20) * 4 / 5 // 4/5 to account for non-heap memory
 		npkg := avail / mem / 2                    // 2 to account for GOGC=100
 		parsed = make([]ParsedPackage, npkg)
-		for n := 0; n < 2; n++ { // warmup GC
+		for range 2 { // warmup GC
 			for i := range parsed {
 				parsed[i] = parsePackage()
 			}
@@ -57,7 +57,7 @@
 	wg.Add(G)
 	remain := int64(N)
 	pos := 0
-	for g := 0; g < G; g++ {
+	for range G {
 		go func() {
 			defer wg.Done()
 			for atomic.AddInt64(&remain, -1) >= 0 {
@@ -97,10 +97,7 @@
 	}
 	ms1 := new(runtime.MemStats)
 	runtime.ReadMemStats(ms1)
-	mem := int(ms1.Alloc-ms0.Alloc) / N
-	if mem < 1<<16 {
-		mem = 1 << 16
-	}
+	mem := max(int(ms1.Alloc-ms0.Alloc)/N, 1<<16)
 	return mem
 }
 
diff --git a/gc_latency/latency.go b/gc_latency/latency.go
index f79d1bb..cfba1f8 100644
--- a/gc_latency/latency.go
+++ b/gc_latency/latency.go
@@ -10,7 +10,7 @@
 	"os"
 	"runtime"
 	"runtime/trace"
-	"sort"
+	"slices"
 	"testing"
 	"time"
 	"unsafe"
@@ -111,7 +111,7 @@
 
 //go:noinline
 func (lb *LB) work(c *circularBuffer, count int) {
-	for i := 0; i < count; i++ {
+	for i := range count {
 		lb.storeSlice(c, i)
 	}
 }
@@ -196,7 +196,7 @@
 	}
 	run()
 
-	sort.Slice(lb.delays, func(i, j int) bool { return lb.delays[i] < lb.delays[j] })
+	slices.Sort(lb.delays)
 	delays := lb.delays
 	delayLen := float64(len(delays))
 	average, median := time.Duration(lb.total.Nanoseconds()/int64(count)), delays[len(delays)/2]
diff --git a/go.mod b/go.mod
index 20681ac..369a273 100644
--- a/go.mod
+++ b/go.mod
@@ -1,6 +1,6 @@
 module golang.org/x/benchmarks
 
-go 1.24.0
+go 1.25.0
 
 require (
 	github.com/BurntSushi/toml v1.0.0
diff --git a/stats/edmx.go b/stats/edmx.go
index 0300a6f..aa26f62 100644
--- a/stats/edmx.go
+++ b/stats/edmx.go
@@ -14,10 +14,10 @@
 func (h maxHeap) Len() int           { return len(h) }
 func (h maxHeap) Less(i, j int) bool { return h[i] > h[j] }
 func (h maxHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }
-func (h *maxHeap) Push(x interface{}) {
+func (h *maxHeap) Push(x any) {
 	*h = append(*h, x.(float64))
 }
-func (h *maxHeap) Pop() interface{} {
+func (h *maxHeap) Pop() any {
 	old := *h
 	n := len(old)
 	x := old[n-1]
@@ -30,10 +30,10 @@
 func (h minHeap) Len() int           { return len(h) }
 func (h minHeap) Less(i, j int) bool { return h[i] < h[j] }
 func (h minHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }
-func (h *minHeap) Push(x interface{}) {
+func (h *minHeap) Push(x any) {
 	*h = append(*h, x.(float64))
 }
-func (h *minHeap) Pop() interface{} {
+func (h *minHeap) Pop() any {
 	old := *h
 	n := len(old)
 	x := old[n-1]
diff --git a/sweet/benchmarks/cockroachdb/main.go b/sweet/benchmarks/cockroachdb/main.go
index fa6a4cf..3648d4a 100644
--- a/sweet/benchmarks/cockroachdb/main.go
+++ b/sweet/benchmarks/cockroachdb/main.go
@@ -174,7 +174,6 @@
 
 	var wg sync.WaitGroup
 	for _, inst := range instances {
-		inst := inst
 		wg.Add(1)
 		go func(context.Context) {
 			defer wg.Done()
diff --git a/sweet/benchmarks/etcd/main.go b/sweet/benchmarks/etcd/main.go
index 444a087..a7045d6 100644
--- a/sweet/benchmarks/etcd/main.go
+++ b/sweet/benchmarks/etcd/main.go
@@ -96,7 +96,7 @@
 
 func launchEtcdCluster(cfg *config) ([]*etcdInstance, error) {
 	var instances []*etcdInstance
-	for i := 0; i < etcdInstances; i++ {
+	for i := range etcdInstances {
 		instances = append(instances, &etcdInstance{
 			name:       fmt.Sprintf("infra%d", i+1),
 			clientPort: basePort + 2*i,
diff --git a/sweet/benchmarks/gvisor/http_server.go b/sweet/benchmarks/gvisor/http_server.go
index 5a4ce24..b848fab 100644
--- a/sweet/benchmarks/gvisor/http_server.go
+++ b/sweet/benchmarks/gvisor/http_server.go
@@ -16,7 +16,7 @@
 	"os/exec"
 	"path/filepath"
 	"runtime"
-	"sort"
+	"slices"
 	"strconv"
 	"syscall"
 	"time"
@@ -165,7 +165,7 @@
 	}, driver.DoTime(true), driver.WithGOMAXPROCS(procs))
 
 	workers := make([]pool.Worker, 0, clients)
-	for i := 0; i < clients; i++ {
+	for range clients {
 		workers = append(workers, newWorker())
 	}
 
@@ -184,9 +184,7 @@
 		for _, w := range workers {
 			latencies = append(latencies, w.(*worker).lat...)
 		}
-		sort.Slice(latencies, func(i, j int) bool {
-			return latencies[i] < latencies[j]
-		})
+		slices.Sort(latencies)
 
 		// Sort and report percentiles.
 		p50 := latencies[len(latencies)*50/100]
diff --git a/sweet/benchmarks/internal/driver/driver.go b/sweet/benchmarks/internal/driver/driver.go
index 403c8fb..ec7a216 100644
--- a/sweet/benchmarks/internal/driver/driver.go
+++ b/sweet/benchmarks/internal/driver/driver.go
@@ -302,9 +302,7 @@
 		return nil
 	}
 	stop := make(chan struct{})
-	b.wg.Add(1)
-	go func() {
-		defer b.wg.Done()
+	b.wg.Go(func() {
 
 		rssSamples := make([]uint64, 0, 1024)
 		for {
@@ -324,7 +322,7 @@
 				rssSamples = append(rssSamples, r)
 			}
 		}
-	}()
+	})
 	return stop
 }
 
@@ -405,7 +403,7 @@
 	fmt.Fprintln(out)
 }
 
-func warningf(format string, args ...interface{}) {
+func warningf(format string, args ...any) {
 	s := fmt.Sprintf(format, args...)
 	s = strings.Join(strings.Split(s, "\n"), "\n# ")
 	fmt.Fprintf(os.Stderr, "# warning: %s\n", s)
@@ -415,7 +413,7 @@
 	avg := uint64(0)
 	lo := uint64(0)
 	l := uint64(len(s))
-	for i := 0; i < len(s); i++ {
+	for i := range s {
 		avg += s[i] / l
 		mod := s[i] % l
 		if lo >= l-mod {
diff --git a/sweet/benchmarks/internal/pool/pool.go b/sweet/benchmarks/internal/pool/pool.go
index d7ce705..e531e4e 100644
--- a/sweet/benchmarks/internal/pool/pool.go
+++ b/sweet/benchmarks/internal/pool/pool.go
@@ -58,7 +58,6 @@
 
 	// Spin up workers.
 	for _, w := range workers {
-		w := w
 		g.Go(func() error {
 			ready.Done()
 			<-gun // wait for starting gun to close
diff --git a/sweet/benchmarks/tile38/main.go b/sweet/benchmarks/tile38/main.go
index 43059c9..cbdb569 100644
--- a/sweet/benchmarks/tile38/main.go
+++ b/sweet/benchmarks/tile38/main.go
@@ -150,7 +150,7 @@
 func runBenchmark(d *driver.B, host string, port, clients int, iters int) error {
 	workers := make([]pool.Worker, 0, clients)
 	iterCount := int64(iters) // Shared atomic variable.
-	for i := 0; i < clients; i++ {
+	for range clients {
 		w, err := newWorker(host, port, &iterCount)
 		if err != nil {
 			return err
diff --git a/sweet/cmd/sweet/run.go b/sweet/cmd/sweet/run.go
index b8388e7..7f78db8 100644
--- a/sweet/cmd/sweet/run.go
+++ b/sweet/cmd/sweet/run.go
@@ -13,6 +13,7 @@
 	"os"
 	"path/filepath"
 	"regexp"
+	"slices"
 	"sort"
 	"strings"
 	"unicode/utf8"
@@ -174,10 +175,7 @@
 		}
 	}
 	if c.runCfg.pgoCount == 0 {
-		c.runCfg.pgoCount = c.runCfg.count
-		if c.runCfg.pgoCount > pgoCountDefaultMax {
-			c.runCfg.pgoCount = pgoCountDefaultMax
-		}
+		c.runCfg.pgoCount = min(c.runCfg.count, pgoCountDefaultMax)
 	}
 
 	var err error
@@ -503,13 +501,7 @@
 
 func checkPlatform() {
 	currentPlatform := common.CurrentPlatform()
-	platformOK := false
-	for _, platform := range common.SupportedPlatforms {
-		if currentPlatform == platform {
-			platformOK = true
-			break
-		}
-	}
+	platformOK := slices.Contains(common.SupportedPlatforms, currentPlatform)
 	if !platformOK {
 		log.Printf("warning: %s is an unsupported platform, use at your own risk!", currentPlatform)
 	}
diff --git a/sweet/common/config.go b/sweet/common/config.go
index df64b6e..9b646a1 100644
--- a/sweet/common/config.go
+++ b/sweet/common/config.go
@@ -8,6 +8,7 @@
 	"bytes"
 	"fmt"
 	"io"
+	"maps"
 	"path/filepath"
 
 	"github.com/BurntSushi/toml"
@@ -96,9 +97,7 @@
 func (c *Config) Copy() *Config {
 	cc := *c
 	cc.PGOFiles = make(map[string]string)
-	for k, v := range c.PGOFiles {
-		cc.PGOFiles[k] = v
-	}
+	maps.Copy(cc.PGOFiles, c.PGOFiles)
 	cc.PGOConfigs = make([]PGOConfig, len(c.PGOConfigs))
 	for i, v := range c.PGOConfigs {
 		cc.PGOConfigs[i] = v
@@ -160,8 +159,8 @@
 	*Env
 }
 
-func (c *ConfigEnv) UnmarshalTOML(data interface{}) error {
-	ldata, ok := data.([]interface{})
+func (c *ConfigEnv) UnmarshalTOML(data any) error {
+	ldata, ok := data.([]any)
 	if !ok {
 		return fmt.Errorf("expected data for env to be a list")
 	}
diff --git a/sweet/common/diagnostics/config.go b/sweet/common/diagnostics/config.go
index 906e2f8..ae7650e 100644
--- a/sweet/common/diagnostics/config.go
+++ b/sweet/common/diagnostics/config.go
@@ -6,6 +6,7 @@
 
 import (
 	"fmt"
+	"maps"
 	"strings"
 )
 
@@ -26,8 +27,8 @@
 }
 
 // UnmarshalTOML implements TOML unmarshaling for ConfigSet.
-func (c *ConfigSet) UnmarshalTOML(data interface{}) error {
-	ldata, ok := data.([]interface{})
+func (c *ConfigSet) UnmarshalTOML(data any) error {
+	ldata, ok := data.([]any)
 	if !ok {
 		return fmt.Errorf("expected data for diagnostics to be a list")
 	}
@@ -50,9 +51,7 @@
 // Copy creates a deep clone of a ConfigSet.
 func (c ConfigSet) Copy() ConfigSet {
 	cfgs := make(map[Type]Config, len(c.cfgs))
-	for k, v := range c.cfgs {
-		cfgs[k] = v
-	}
+	maps.Copy(cfgs, c.cfgs)
 	return ConfigSet{cfgs}
 }
 
diff --git a/sweet/common/diagnostics/driver.go b/sweet/common/diagnostics/driver.go
index a3bbafb..3753fdd 100644
--- a/sweet/common/diagnostics/driver.go
+++ b/sweet/common/diagnostics/driver.go
@@ -37,7 +37,6 @@
 
 	f.StringVar(&c.ResultsDir, "results-dir", "", "directory to write diagnostics data")
 	for _, t := range Types() {
-		t := t
 		if t == Perf {
 			f.Func(string(t), fmt.Sprintf("enable %s diagnostics with `flags`", t), func(s string) error {
 				c.cfgs[t] = Config{Type: t, Flags: s}
diff --git a/sweet/common/log/log.go b/sweet/common/log/log.go
index ffa99bd..9ddab1b 100644
--- a/sweet/common/log/log.go
+++ b/sweet/common/log/log.go
@@ -96,21 +96,21 @@
 	cmdLog.Printf("killall -SIGINT %s", filepath.Base(cmd.Path))
 }
 
-func CommandPrintf(format string, args ...interface{}) {
+func CommandPrintf(format string, args ...any) {
 	if !cmdOn {
 		return
 	}
 	cmdLog.Printf(format, args...)
 }
 
-func Printf(format string, args ...interface{}) {
+func Printf(format string, args ...any) {
 	if !actOn {
 		return
 	}
 	actLog.Printf(format, args...)
 }
 
-func Print(args ...interface{}) {
+func Print(args ...any) {
 	if !actOn {
 		return
 	}
diff --git a/sweet/generators/tile38.go b/sweet/generators/tile38.go
index ed95bb6..5d05854 100644
--- a/sweet/generators/tile38.go
+++ b/sweet/generators/tile38.go
@@ -105,7 +105,7 @@
 	srvCmd, err := launchServer(serverPath, tmpDataPath, &buf)
 	if err != nil {
 		log.Printf("=== Server stdout+stderr ===")
-		for _, line := range strings.Split(buf.String(), "\n") {
+		for line := range strings.SplitSeq(buf.String(), "\n") {
 			log.Print(line)
 		}
 		return fmt.Errorf("error: starting server: %w", err)
@@ -131,7 +131,7 @@
 		}
 		if err != nil && buf.Len() != 0 {
 			log.Printf("=== Server stdout+stderr ===")
-			for _, line := range strings.Split(buf.String(), "\n") {
+			for line := range strings.SplitSeq(buf.String(), "\n") {
 				log.Print(line)
 			}
 		}
diff --git a/sweet/source-assets/gvisor/syscall/syscall-bench.go b/sweet/source-assets/gvisor/syscall/syscall-bench.go
index d4d709f..1a8cb4e 100644
--- a/sweet/source-assets/gvisor/syscall/syscall-bench.go
+++ b/sweet/source-assets/gvisor/syscall/syscall-bench.go
@@ -9,7 +9,7 @@
 var ppid int
 
 func main() {
-	for i := 0; i < 500000; i++ {
+	for range 500000 {
 		ppid = os.Getppid()
 	}
 }
diff --git a/third_party/biogo-examples/igor/igor/cluster.go b/third_party/biogo-examples/igor/igor/cluster.go
index 0c19bf4..4dd0171 100644
--- a/third_party/biogo-examples/igor/igor/cluster.go
+++ b/third_party/biogo-examples/igor/igor/cluster.go
@@ -16,20 +16,6 @@
 	"github.com/biogo/store/step"
 )
 
-func min(a, b int) int {
-	if a < b {
-		return a
-	}
-	return b
-}
-
-func max(a, b int) int {
-	if a > b {
-		return a
-	}
-	return b
-}
-
 func within(alpha float64, short, long int) bool {
 	return float64(short) >= float64(long)*(1-alpha)
 }