diff options
| author | Shulhan <ms@kilabit.info> | 2025-01-23 03:40:50 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2025-01-23 03:41:10 +0700 |
| commit | 2a0694d2fa577574b505c4635eb8a824eaf88ddc (patch) | |
| tree | cce840739c7f59893c3a6a65a1600f9f857c484e /lib/net | |
| parent | 605d847b236dde031a2e387e74298d66a27b5e0a (diff) | |
| download | pakakeh.go-2a0694d2fa577574b505c4635eb8a824eaf88ddc.tar.xz | |
all: use for-range with numeric
Go 1.22 now support for-range on numeric value.
Diffstat (limited to 'lib/net')
| -rw-r--r-- | lib/net/net.go | 12 | ||||
| -rw-r--r-- | lib/net/poll_bsd.go | 12 | ||||
| -rw-r--r-- | lib/net/poll_linux.go | 12 |
3 files changed, 16 insertions, 20 deletions
diff --git a/lib/net/net.go b/lib/net/net.go index 4add0435..e52831d1 100644 --- a/lib/net/net.go +++ b/lib/net/net.go @@ -1,6 +1,6 @@ -// Copyright 2018, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2018 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause // Package net provide constants and library for networking. package net @@ -176,14 +176,14 @@ func ToDotIPv6(ip net.IP) (out []byte) { addrs := strings.Split(ip.String(), ":") var notempty int - for x := 0; x < len(addrs); x++ { + for x := range len(addrs) { if len(addrs[x]) != 0 { notempty++ } } gap := 8 - notempty - for x := 0; x < len(addrs); x++ { + for x := range len(addrs) { addr := addrs[x] // Fill the gap "::" with one or more "0.0.0.0". @@ -205,7 +205,7 @@ func ToDotIPv6(ip net.IP) (out []byte) { out = append(out, '0') } - for y := 0; y < len(addr); y++ { + for y := range len(addr) { if len(out) > 0 { out = append(out, '.') } diff --git a/lib/net/poll_bsd.go b/lib/net/poll_bsd.go index 80340fa7..668c3f58 100644 --- a/lib/net/poll_bsd.go +++ b/lib/net/poll_bsd.go @@ -1,6 +1,6 @@ -// Copyright 2019, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2019 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause //go:build darwin || dragonfly || freebsd || netbsd || openbsd @@ -81,7 +81,6 @@ func (poll *kqueue) WaitRead() (fds []int, err error) { logp = `WaitRead` n int - x int fd int ) for n == 0 { @@ -94,7 +93,7 @@ func (poll *kqueue) WaitRead() (fds []int, err error) { } } - for x = 0; x < n; x++ { + for x := range n { if poll.events[x].Filter != unix.EVFILT_READ { continue } @@ -124,7 +123,6 @@ func (poll *kqueue) WaitReadEvents() (events []PollEvent, err error) { logp = `WaitReadEvents` n int - x int fd int ) @@ -138,7 +136,7 @@ func (poll *kqueue) WaitReadEvents() (events []PollEvent, err error) { } } - for x = 0; x < n; x++ { + for x := range n { if poll.events[x].Filter != unix.EVFILT_READ { continue } diff --git a/lib/net/poll_linux.go b/lib/net/poll_linux.go index 69cf56b5..e10fe88b 100644 --- a/lib/net/poll_linux.go +++ b/lib/net/poll_linux.go @@ -1,6 +1,6 @@ -// Copyright 2019, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2019 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause //go:build linux @@ -71,7 +71,6 @@ func (poll *epoll) WaitRead() (fds []int, err error) { logp = `WaitRead` n int - x int fd int ) for { @@ -85,7 +84,7 @@ func (poll *epoll) WaitRead() (fds []int, err error) { break } - for x = 0; x < n; x++ { + for x := range n { fd = int(poll.events[x].Fd) err = poll.UnregisterRead(fd) @@ -111,7 +110,6 @@ func (poll *epoll) WaitReadEvents() (events []PollEvent, err error) { logp = `WaitReadEvents` n int - x int fd int ) @@ -126,7 +124,7 @@ func (poll *epoll) WaitReadEvents() (events []PollEvent, err error) { break } - for x = 0; x < n; x++ { + for x := range n { fd = int(poll.events[x].Fd) err = poll.UnregisterRead(fd) |
