Skip to content

Commit 0c001ca

Browse files
authored
refactor: replace Split in loops with more efficient SplitSeq (#2502)
<!-- Please read and fill out this form before submitting your PR. Please make sure you have reviewed our contributors guide before submitting your first PR. NOTE: PR titles should follow semantic commits: https://www.conventionalcommits.org/en/v1.0.0/ --> ## Overview <!-- Please provide an explanation of the PR, including the appropriate context, background, goal, and rationale. If there is an issue with this information, please provide a tl;dr and link the issue. Ex: Closes #<issue number> --> Optimize code using a more modern writing style which can make the code more efficient and cleaner. Official support by Go Team. https://pkg.go.dev/golang.org/x/tools/gopls/internal/analysis/modernize. Signed-off-by: pinglanlu <[email protected]>
1 parent 967b6b9 commit 0c001ca

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pkg/sync/sync_service.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,9 +385,9 @@ func getPeers(seeds string, logger logging.EventLogger) []peer.ID {
385385
if seeds == "" {
386386
return peerIDs
387387
}
388-
sl := strings.Split(seeds, ",")
388+
sl := strings.SplitSeq(seeds, ",")
389389

390-
for _, seed := range sl {
390+
for seed := range sl {
391391
maddr, err := multiaddr.NewMultiaddr(seed)
392392
if err != nil {
393393
logger.Error("failed to parse peer", "address", seed, "error", err)

0 commit comments

Comments
 (0)