Skip to content

Commit c93496b

Browse files
author
1911860538
committed
all: replace strings.Split with strings.SplitSeq
1 parent 8003858 commit c93496b

File tree

8 files changed

+10
-10
lines changed

8 files changed

+10
-10
lines changed

src/go/ast/ast.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1123,7 +1123,7 @@ func generator(file *File) (string, bool) {
11231123
// opt: check Contains first to avoid unnecessary array allocation in Split.
11241124
const prefix = "// Code generated "
11251125
if strings.Contains(comment.Text, prefix) {
1126-
for _, line := range strings.Split(comment.Text, "\n") {
1126+
for line := range strings.SplitSeq(comment.Text, "\n") {
11271127
if rest, ok := strings.CutPrefix(line, prefix); ok {
11281128
if gen, ok := strings.CutSuffix(rest, " DO NOT EDIT."); ok {
11291129
return gen, true

src/go/build/build.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1708,7 +1708,7 @@ Lines:
17081708
// that affect the way cgo's C code is built.
17091709
func (ctxt *Context) saveCgo(filename string, di *Package, cg *ast.CommentGroup) error {
17101710
text := cg.Text()
1711-
for _, line := range strings.Split(text, "\n") {
1711+
for line := range strings.SplitSeq(text, "\n") {
17121712
orig := line
17131713

17141714
// Line is

src/go/build/constraint/expr.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,9 +406,9 @@ func parsePlusBuildExpr(text string) (Expr, error) {
406406
size := 0
407407

408408
var x Expr
409-
for _, clause := range strings.Fields(text) {
409+
for clause := range strings.FieldsSeq(text) {
410410
var y Expr
411-
for _, lit := range strings.Split(clause, ",") {
411+
for lit := range strings.SplitSeq(clause, ",") {
412412
var z Expr
413413
var neg bool
414414
if strings.HasPrefix(lit, "!!") || lit == "!" {

src/internal/buildcfg/cfg.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ func (f gowasmFeatures) String() string {
336336
}
337337

338338
func gowasm() (f gowasmFeatures) {
339-
for _, opt := range strings.Split(envOr("GOWASM", ""), ",") {
339+
for opt := range strings.SplitSeq(envOr("GOWASM", ""), ",") {
340340
switch opt {
341341
case "satconv":
342342
f.SatConv = true

src/internal/buildcfg/exp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func ParseGOEXPERIMENT(goos, goarch, goexp string) (*ExperimentFlags, error) {
113113
}
114114

115115
// Parse names.
116-
for _, f := range strings.Split(goexp, ",") {
116+
for f := range strings.SplitSeq(goexp, ",") {
117117
if f == "" {
118118
continue
119119
}

src/internal/testenv/testenv.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ func WriteImportcfg(t testing.TB, dstPath string, packageFiles map[string]string
484484
t.Fatalf("%v: %v\n%s", cmd, err, cmd.Stderr)
485485
}
486486

487-
for _, line := range strings.Split(string(out), "\n") {
487+
for line := range strings.SplitSeq(string(out), "\n") {
488488
if line == "" {
489489
continue
490490
}

src/internal/trace/traceviewer/mmu.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ var utilFlagNames = map[string]trace.UtilFlags{
6969

7070
func requestUtilFlags(r *http.Request) trace.UtilFlags {
7171
var flags trace.UtilFlags
72-
for _, flagStr := range strings.Split(r.FormValue("flags"), "|") {
72+
for flagStr := range strings.SplitSeq(r.FormValue("flags"), "|") {
7373
flags |= utilFlagNames[flagStr]
7474
}
7575
return flags
@@ -119,7 +119,7 @@ func (m *mmu) HandlePlot(w http.ResponseWriter, r *http.Request) {
119119
}
120120

121121
var quantiles []float64
122-
for _, flagStr := range strings.Split(r.FormValue("flags"), "|") {
122+
for flagStr := range strings.SplitSeq(r.FormValue("flags"), "|") {
123123
if flagStr == "mut" {
124124
quantiles = []float64{0, 1 - .999, 1 - .99, 1 - .95}
125125
break

src/os/exec/lp_windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func pathExt() []string {
123123
var exts []string
124124
x := os.Getenv(`PATHEXT`)
125125
if x != "" {
126-
for _, e := range strings.Split(strings.ToLower(x), `;`) {
126+
for e := range strings.SplitSeq(strings.ToLower(x), `;`) {
127127
if e == "" {
128128
continue
129129
}

0 commit comments

Comments
 (0)