modernizes for loop in cmd/, internal/ (#21309)

This commit is contained in:
ILIYA
2025-05-28 00:19:03 +09:00
committed by GitHub
parent ea77bcfc98
commit 0a36d41dcd
27 changed files with 44 additions and 44 deletions

View File

@@ -381,7 +381,7 @@ func refreshLock(ctx context.Context, ds *Dsync, id, source string, quorum int)
lockNotFound, lockRefreshed := 0, 0
done := false
for i := 0; i < len(restClnts); i++ {
for range len(restClnts) {
select {
case refreshResult := <-ch:
if refreshResult.offline {

View File

@@ -357,7 +357,7 @@ func (list *TargetList) startSendWorkers(workerCount int) {
if err != nil {
panic(err)
}
for i := 0; i < workerCount; i++ {
for range workerCount {
wk.Take()
go func() {
defer wk.Give()

View File

@@ -1041,7 +1041,7 @@ func (c *Connection) readStream(ctx context.Context, conn net.Conn, cancel conte
// Handle merged messages.
messages := int(m.Seq)
c.inMessages.Add(int64(messages))
for i := 0; i < messages; i++ {
for range messages {
if atomic.LoadUint32((*uint32)(&c.state)) != StateConnected {
return
}

View File

@@ -143,7 +143,7 @@ func (t *TestGrid) WaitAllConnect(ctx context.Context) {
}
func getHosts(n int) (hosts []string, listeners []net.Listener, err error) {
for i := 0; i < n; i++ {
for range n {
l, err := net.Listen("tcp", "127.0.0.1:0")
if err != nil {
if l, err = net.Listen("tcp6", "[::1]:0"); err != nil {

View File

@@ -574,7 +574,7 @@ func (m *muxClient) ack(seq uint32) {
return
}
available := cap(m.outBlock)
for i := 0; i < available; i++ {
for range available {
m.outBlock <- struct{}{}
}
m.acked = true

View File

@@ -130,7 +130,7 @@ func newMuxStream(ctx context.Context, msg message, c *Connection, handler Strea
// Fill outbound block.
// Each token represents a message that can be sent to the client without blocking.
// The client will refill the tokens as they confirm delivery of the messages.
for i := 0; i < outboundCap; i++ {
for range outboundCap {
m.outBlock <- struct{}{}
}

View File

@@ -230,7 +230,7 @@ func (r *Reader) startReaders(newReader func(io.Reader) *csv.Reader) error {
}()
// Start parsers
for i := 0; i < runtime.GOMAXPROCS(0); i++ {
for range runtime.GOMAXPROCS(0) {
go func() {
for in := range r.input {
if len(in.input) == 0 {

View File

@@ -173,7 +173,7 @@ func (r *PReader) startReaders() {
}()
// Start parsers
for i := 0; i < runtime.GOMAXPROCS(0); i++ {
for range runtime.GOMAXPROCS(0) {
go func() {
for in := range r.input {
if len(in.input) == 0 {

View File

@@ -332,7 +332,7 @@ func (d *Decoder) u4() rune {
// logic taken from:
// github.com/buger/jsonparser/blob/master/escape.go#L20
var h [4]int
for i := 0; i < 4; i++ {
for i := range 4 {
c := d.next()
switch {
case c >= '0' && c <= '9':