From 2a0694d2fa577574b505c4635eb8a824eaf88ddc Mon Sep 17 00:00:00 2001 From: Shulhan Date: Thu, 23 Jan 2025 03:40:50 +0700 Subject: all: use for-range with numeric Go 1.22 now support for-range on numeric value. --- lib/bytes/bytes.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/bytes/bytes.go') diff --git a/lib/bytes/bytes.go b/lib/bytes/bytes.go index ae1c9234..f0f55555 100644 --- a/lib/bytes/bytes.go +++ b/lib/bytes/bytes.go @@ -154,9 +154,9 @@ func InReplace(text, allowed []byte, c byte) []byte { } var found bool - for x := 0; x < len(text); x++ { + for x := range len(text) { found = false - for y := 0; y < len(allowed); y++ { + for y := range len(allowed) { if text[x] == allowed[y] { found = true break @@ -207,7 +207,7 @@ func IsTokenAt(text, token []byte, p int) bool { return false } - for x := 0; x < tokenlen; x++ { + for x := range tokenlen { if text[p] != token[x] { return false } @@ -370,7 +370,7 @@ func SplitEach(data []byte, n int) (chunks [][]byte) { rows = (size / n) total int ) - for x := 0; x < rows; x++ { + for range rows { chunks = append(chunks, data[total:total+n]) total += n } -- cgit v1.3