Skip to content

Commit 154bc3f

Browse files
committed
all: use strings.SplitSeq to range strings.Split
1 parent b49f6cb commit 154bc3f

File tree

9 files changed

+15
-15
lines changed

9 files changed

+15
-15
lines changed

cmd/XDC/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ func loadBaseConfig(ctx *cli.Context) XDCConfig {
175175
for _, env := range cfg.Account.Passwords {
176176
if trimmed := strings.TrimSpace(env); trimmed != "" {
177177
value := os.Getenv(trimmed)
178-
for _, info := range strings.Split(value, ",") {
178+
for info := range strings.SplitSeq(value, ",") {
179179
if trimmed2 := strings.TrimSpace(info); trimmed2 != "" {
180180
passwords = append(passwords, trimmed2)
181181
}

cmd/utils/flags.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1897,7 +1897,7 @@ func MakeConsolePreloads(ctx *cli.Context) []string {
18971897
preloads := []string{}
18981898

18991899
assets := ctx.String(JSpathFlag.Name)
1900-
for _, file := range strings.Split(ctx.String(PreloadJSFlag.Name), ",") {
1900+
for file := range strings.SplitSeq(ctx.String(PreloadJSFlag.Name), ",") {
19011901
preloads = append(preloads, common.AbsolutePath(assets, strings.TrimSpace(file)))
19021902
}
19031903
return preloads

eth/backend.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func New(stack *node.Node, config *ethconfig.Config, XDCXServ *XDCx.XDCX, lendin
129129
common.CopyConstants(networkID)
130130

131131
log.Info(strings.Repeat("-", 153))
132-
for _, line := range strings.Split(chainConfig.Description(), "\n") {
132+
for line := range strings.SplitSeq(chainConfig.Description(), "\n") {
133133
log.Info(line)
134134
}
135135
log.Info(strings.Repeat("-", 153))

internal/build/util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func ExpandPackages(patterns []string, quick bool) []string {
151151
log.Fatalf("package listing failed: %v\n%s", err, string(out))
152152
}
153153
var packages []string
154-
for _, line := range strings.Split(string(out), "\n") {
154+
for line := range strings.SplitSeq(string(out), "\n") {
155155
if strings.Contains(line, "/vendor/") {
156156
continue
157157
}

log/handler_glog.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func (h *GlogHandler) Verbosity(level slog.Level) {
8686
// sets V to 3 in all files of any packages whose import path contains "foo"
8787
func (h *GlogHandler) Vmodule(ruleset string) error {
8888
var filter []pattern
89-
for _, rule := range strings.Split(ruleset, ",") {
89+
for rule := range strings.SplitSeq(ruleset, ",") {
9090
// Empty strings such as from a trailing comma can be ignored
9191
if len(rule) == 0 {
9292
continue
@@ -113,7 +113,7 @@ func (h *GlogHandler) Vmodule(ruleset string) error {
113113
}
114114
// Compile the rule pattern into a regular expression
115115
matcher := ".*"
116-
for _, comp := range strings.Split(parts[0], "/") {
116+
for comp := range strings.SplitSeq(parts[0], "/") {
117117
if comp == "*" {
118118
matcher += "(/.*)?"
119119
} else if comp != "" {

node/api.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,19 +205,19 @@ func (api *adminAPI) StartHTTP(host *string, port *int, cors *string, apis *stri
205205
}
206206
if cors != nil {
207207
config.CorsAllowedOrigins = nil
208-
for _, origin := range strings.Split(*cors, ",") {
208+
for origin := range strings.SplitSeq(*cors, ",") {
209209
config.CorsAllowedOrigins = append(config.CorsAllowedOrigins, strings.TrimSpace(origin))
210210
}
211211
}
212212
if vhosts != nil {
213213
config.Vhosts = nil
214-
for _, vhost := range strings.Split(*host, ",") {
214+
for vhost := range strings.SplitSeq(*host, ",") {
215215
config.Vhosts = append(config.Vhosts, strings.TrimSpace(vhost))
216216
}
217217
}
218218
if apis != nil {
219219
config.Modules = nil
220-
for _, m := range strings.Split(*apis, ",") {
220+
for m := range strings.SplitSeq(*apis, ",") {
221221
config.Modules = append(config.Modules, strings.TrimSpace(m))
222222
}
223223
}
@@ -283,13 +283,13 @@ func (api *adminAPI) StartWS(host *string, port *int, allowedOrigins *string, ap
283283

284284
if apis != nil {
285285
config.Modules = nil
286-
for _, m := range strings.Split(*apis, ",") {
286+
for m := range strings.SplitSeq(*apis, ",") {
287287
config.Modules = append(config.Modules, strings.TrimSpace(m))
288288
}
289289
}
290290
if allowedOrigins != nil {
291291
config.Origins = nil
292-
for _, origin := range strings.Split(*allowedOrigins, ",") {
292+
for origin := range strings.SplitSeq(*allowedOrigins, ",") {
293293
config.Origins = append(config.Origins, strings.TrimSpace(origin))
294294
}
295295
}

p2p/simulations/http.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,13 +480,13 @@ func (s *Server) StreamNetworkEvents(w http.ResponseWriter, req *http.Request) {
480480
// A message code of '*' or '-1' is considered a wildcard and matches any code.
481481
func NewMsgFilters(filterParam string) (MsgFilters, error) {
482482
filters := make(MsgFilters)
483-
for _, filter := range strings.Split(filterParam, "-") {
483+
for filter := range strings.SplitSeq(filterParam, "-") {
484484
proto, codes, found := strings.Cut(filter, ":")
485485
if !found || proto == "" || codes == "" {
486486
return nil, fmt.Errorf("invalid message filter: %s", filter)
487487
}
488488

489-
for _, code := range strings.Split(codes, ",") {
489+
for code := range strings.SplitSeq(codes, ",") {
490490
if code == "*" || code == "-1" {
491491
filters[MsgFilter{Proto: proto, Code: -1}] = struct{}{}
492492
continue

rlp/internal/rlpstruct/rlpstruct.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func parseTag(field Field, lastPublic int) (Tags, error) {
148148
name := field.Name
149149
tag := reflect.StructTag(field.Tag)
150150
var ts Tags
151-
for _, t := range strings.Split(tag.Get("rlp"), ",") {
151+
for t := range strings.SplitSeq(tag.Get("rlp"), ",") {
152152
switch t = strings.TrimSpace(t); t {
153153
case "":
154154
// empty tag is allowed for some reason

rpc/server_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func runTestScript(t *testing.T, file string) {
9292
defer clientConn.Close()
9393
go server.ServeCodec(NewCodec(serverConn), 0)
9494
readbuf := bufio.NewReader(clientConn)
95-
for _, line := range strings.Split(string(content), "\n") {
95+
for line := range strings.SplitSeq(string(content), "\n") {
9696
line = strings.TrimSpace(line)
9797
switch {
9898
case len(line) == 0 || strings.HasPrefix(line, "//"):

0 commit comments

Comments
 (0)