diff --git a/src/crypto/internal/fips140deps/fipsdeps_test.go b/src/crypto/internal/fips140deps/fipsdeps_test.go
index e2d1d18..80ddc38 100644
--- a/src/crypto/internal/fips140deps/fipsdeps_test.go
+++ b/src/crypto/internal/fips140deps/fipsdeps_test.go
@@ -64,7 +64,7 @@
// importCheck is the set of packages that import crypto/internal/fips140/check.
importCheck := make(map[string]bool)
- for _, line := range strings.Split(out, "\n") {
+ for line := range strings.SplitSeq(out, "\n") {
if line == "" {
continue
}
diff --git a/src/crypto/purego_test.go b/src/crypto/purego_test.go
index ebc9110..14e2272 100644
--- a/src/crypto/purego_test.go
+++ b/src/crypto/purego_test.go
@@ -35,7 +35,7 @@
log.Fatalf("loading architecture list: %v\n%s", err, out)
}
allGOARCH := make(map[string]bool)
- for _, pair := range strings.Split(strings.TrimSpace(string(out)), "\n") {
+ for pair := range strings.SplitSeq(strings.TrimSpace(string(out)), "\n") {
GOARCH := strings.Split(pair, "/")[1]
allGOARCH[GOARCH] = true
}
diff --git a/src/crypto/tls/handshake_test.go b/src/crypto/tls/handshake_test.go
index 7191ced..2394ee5 100644
--- a/src/crypto/tls/handshake_test.go
+++ b/src/crypto/tls/handshake_test.go
@@ -212,8 +212,8 @@
}
line = before
- hexBytes := strings.Fields(line)
- for _, hexByte := range hexBytes {
+ hexBytes := strings.FieldsSeq(line)
+ for hexByte := range hexBytes {
val, err := strconv.ParseUint(hexByte, 16, 8)
if err != nil {
return nil, errors.New("invalid hex byte in test data: " + err.Error())
diff --git a/src/database/sql/fakedb_test.go b/src/database/sql/fakedb_test.go
index e5f0459..612ed95 100644
--- a/src/database/sql/fakedb_test.go
+++ b/src/database/sql/fakedb_test.go
@@ -633,7 +633,7 @@
c.touchMem()
var firstStmt, prev *fakeStmt
- for _, query := range strings.Split(query, ";") {
+ for query := range strings.SplitSeq(query, ";") {
parts := strings.Split(query, "|")
if len(parts) < 1 {
return nil, errf("empty query")
diff --git a/src/flag/example_test.go b/src/flag/example_test.go
index 088447d..36bb0a2 100644
--- a/src/flag/example_test.go
+++ b/src/flag/example_test.go
@@ -51,7 +51,7 @@
if len(*i) > 0 {
return errors.New("interval flag already set")
}
- for _, dt := range strings.Split(value, ",") {
+ for dt := range strings.SplitSeq(value, ",") {
duration, err := time.ParseDuration(dt)
if err != nil {
return err
diff --git a/src/go/build/constraint/expr_test.go b/src/go/build/constraint/expr_test.go
index f0d0895..eed049f 100644
--- a/src/go/build/constraint/expr_test.go
+++ b/src/go/build/constraint/expr_test.go
@@ -188,7 +188,7 @@
}
tags := make(map[string]bool)
wantTags := make(map[string]bool)
- for _, tag := range strings.Fields(tt.tags) {
+ for tag := range strings.FieldsSeq(tt.tags) {
wantTags[tag] = true
}
hasTag := func(tag string) bool {
diff --git a/src/go/build/vendor_test.go b/src/go/build/vendor_test.go
index 7f6237f..2e5c40a 100644
--- a/src/go/build/vendor_test.go
+++ b/src/go/build/vendor_test.go
@@ -33,7 +33,7 @@
if err != nil {
t.Fatal(err)
}
- for _, fullPkg := range strings.Split(string(out), "\n") {
+ for fullPkg := range strings.SplitSeq(string(out), "\n") {
pkg, found := strings.CutPrefix(fullPkg, "vendor/")
if !found {
_, pkg, found = strings.Cut(fullPkg, "/vendor/")
diff --git a/src/go/doc/comment/std_test.go b/src/go/doc/comment/std_test.go
index 9077af0..de7f01c 100644
--- a/src/go/doc/comment/std_test.go
+++ b/src/go/doc/comment/std_test.go
@@ -21,7 +21,7 @@
}
var list []string
- for _, pkg := range strings.Fields(string(out)) {
+ for pkg := range strings.FieldsSeq(string(out)) {
if !strings.Contains(pkg, "/") {
list = append(list, pkg)
}
diff --git a/src/internal/fuzz/pcg.go b/src/internal/fuzz/pcg.go
index a6fa42f..89d9626 100644
--- a/src/internal/fuzz/pcg.go
+++ b/src/internal/fuzz/pcg.go
@@ -42,8 +42,8 @@
}
func godebugSeed() *int {
- debug := strings.Split(os.Getenv("GODEBUG"), ",")
- for _, f := range debug {
+ debug := strings.SplitSeq(os.Getenv("GODEBUG"), ",")
+ for f := range debug {
if after, ok := strings.CutPrefix(f, "fuzzseed="); ok {
seed, err := strconv.Atoi(after)
if err != nil {
diff --git a/src/internal/godebug/godebug_test.go b/src/internal/godebug/godebug_test.go
index f83d792..581129c 100644
--- a/src/internal/godebug/godebug_test.go
+++ b/src/internal/godebug/godebug_test.go
@@ -120,7 +120,7 @@
slices.Sort(want)
var have []string
- for _, line := range strings.Split(string(out), "\n") {
+ for line := range strings.SplitSeq(string(out), "\n") {
if strings.Contains(line, "godebug_test.go:") {
have = append(have, line[strings.LastIndex(line, "godebug_test.go:"):])
}
diff --git a/src/internal/godebugs/godebugs_test.go b/src/internal/godebugs/godebugs_test.go
index e242f58..9fef9dc 100644
--- a/src/internal/godebugs/godebugs_test.go
+++ b/src/internal/godebugs/godebugs_test.go
@@ -69,7 +69,7 @@
}
seen := map[string]bool{}
- for _, dir := range strings.Split(string(out), "\n") {
+ for dir := range strings.SplitSeq(string(out), "\n") {
if dir == "" {
continue
}
diff --git a/src/internal/testenv/testenv.go b/src/internal/testenv/testenv.go
index 96eacc6..1945994 100644
--- a/src/internal/testenv/testenv.go
+++ b/src/internal/testenv/testenv.go
@@ -174,7 +174,7 @@
// Add all environment variables that affect the Go command to test metadata.
// Cached test results will be invalidate when these variables change.
// See golang.org/issue/32285.
- for _, envVar := range strings.Fields(cfg.KnownEnv) {
+ for envVar := range strings.FieldsSeq(cfg.KnownEnv) {
os.Getenv(envVar)
}
return path
diff --git a/src/math/rand/v2/regress_test.go b/src/math/rand/v2/regress_test.go
index e808b25..7028fe0 100644
--- a/src/math/rand/v2/regress_test.go
+++ b/src/math/rand/v2/regress_test.go
@@ -182,7 +182,7 @@
var buf bytes.Buffer
fmt.Fprintf(&buf, "\t// Output:\n")
- for _, line := range strings.Split(string(out), "\n") {
+ for line := range strings.SplitSeq(string(out), "\n") {
if line != "" {
fmt.Fprintf(&buf, "\t// %s\n", line)
}
diff --git a/src/net/http/example_filesystem_test.go b/src/net/http/example_filesystem_test.go
index da1f0df..233108e 100644
--- a/src/net/http/example_filesystem_test.go
+++ b/src/net/http/example_filesystem_test.go
@@ -16,8 +16,8 @@
// The name is assumed to be a delimited by forward slashes, as guaranteed
// by the http.FileSystem interface.
func containsDotFile(name string) bool {
- parts := strings.Split(name, "/")
- for _, part := range parts {
+ parts := strings.SplitSeq(name, "/")
+ for part := range parts {
if strings.HasPrefix(part, ".") {
return true
}
diff --git a/src/runtime/pprof/pprof_test.go b/src/runtime/pprof/pprof_test.go
index f1d8577..c41c18a 100644
--- a/src/runtime/pprof/pprof_test.go
+++ b/src/runtime/pprof/pprof_test.go
@@ -759,7 +759,7 @@
// stackContainsAll matches if all functions in spec (comma-separated) appear somewhere in the stack trace.
func stackContainsAll(spec string, count uintptr, stk []*profile.Location, labels map[string][]string) bool {
- for _, f := range strings.Split(spec, ",") {
+ for f := range strings.SplitSeq(spec, ",") {
if !stackContains(f, count, stk, labels) {
return false
}
diff --git a/src/syscall/syscall_linux_test.go b/src/syscall/syscall_linux_test.go
index 8ec47a4..a160d10 100644
--- a/src/syscall/syscall_linux_test.go
+++ b/src/syscall/syscall_linux_test.go
@@ -428,8 +428,8 @@
// "... : bad file descriptor.
continue
}
- lines := strings.Split(string(d), "\n")
- for _, line := range lines {
+ lines := strings.SplitSeq(string(d), "\n")
+ for line := range lines {
// Different kernel vintages pad differently.
line = strings.TrimSpace(line)
if strings.HasPrefix(line, "Pid:\t") {
diff --git a/src/testing/testing_test.go b/src/testing/testing_test.go
index 5340c50..4d0ca99 100644
--- a/src/testing/testing_test.go
+++ b/src/testing/testing_test.go
@@ -1142,7 +1142,7 @@
t.Fatalf("want artifact directory contained in %q, got %q", outputDir, artifactDir)
}
- for _, part := range strings.Split(relDir, string(os.PathSeparator)) {
+ for part := range strings.SplitSeq(relDir, string(os.PathSeparator)) {
const maxSize = 64
if len(part) > maxSize {
t.Errorf("artifact directory %q contains component >%v characters long: %q", relDir, maxSize, part)