From e9a11015ecb0864e088218869c2a94d0b5ff30ee Mon Sep 17 00:00:00 2001 From: Andy Pan Date: Sun, 5 Jan 2025 15:33:57 +0800 Subject: [PATCH] test: add an example for the netpoll package (#670) Besides, delete all old build constraints. --- acceptor_unix.go | 1 - client_test.go | 1 - client_unix.go | 1 - conn_map.go | 2 - conn_matrix.go | 2 - conn_matrix_test.go | 2 - connection_bsd.go | 1 - connection_unix.go | 1 - engine_unix.go | 1 - eventloop_unix.go | 1 - eventloop_unix_test.go | 1 - listener_unix.go | 1 - os_unix_test.go | 1 - os_windows_test.go | 1 - pkg/io/io_bsd.go | 1 - pkg/netpoll/defs_bsd_32bit.go | 2 - pkg/netpoll/defs_bsd_64bit.go | 2 - pkg/netpoll/defs_linux.go | 1 - pkg/netpoll/defs_linux_386.go | 1 - pkg/netpoll/defs_linux_amd64.go | 1 - pkg/netpoll/defs_linux_arm.go | 1 - pkg/netpoll/defs_linux_arm64.go | 1 - pkg/netpoll/defs_linux_mips64x.go | 3 - pkg/netpoll/defs_linux_mipsx.go | 3 - pkg/netpoll/defs_linux_ppc64.go | 1 - pkg/netpoll/defs_linux_ppc64le.go | 1 - pkg/netpoll/defs_linux_riscv64.go | 1 - pkg/netpoll/defs_linux_s390x.go | 1 - pkg/netpoll/defs_poller.go | 1 - pkg/netpoll/defs_poller_bsd.go | 1 - pkg/netpoll/defs_poller_epoll.go | 1 - pkg/netpoll/defs_poller_kqueue.go | 1 - pkg/netpoll/example_test.go | 155 ++++++++++++++++++ pkg/netpoll/netpoll.go | 44 +++-- pkg/netpoll/poller_epoll_default.go | 1 - pkg/netpoll/poller_epoll_ultimate.go | 1 - pkg/netpoll/poller_kqueue_default.go | 2 - pkg/netpoll/poller_kqueue_ultimate.go | 2 - pkg/netpoll/poller_kqueue_wakeup.go | 1 - pkg/netpoll/poller_kqueue_wakeup1.go | 1 - pkg/netpoll/poller_unix_ultimate.go | 2 - pkg/netpoll/syscall_epoll_generic_linux.go | 1 - pkg/netpoll/syscall_epoll_linux.go | 1 - .../syscall_epoll_riscv64_arm64_linux.go | 2 - pkg/netpoll/syscall_errors_linux.go | 1 - pkg/socket/fd_unix.go | 1 - pkg/socket/sock_bsd.go | 1 - pkg/socket/sock_cloexec.go | 1 - pkg/socket/sock_posix.go | 1 - pkg/socket/socket.go | 1 - pkg/socket/sockopts_bsd.go | 1 - pkg/socket/sockopts_posix.go | 1 - pkg/socket/sockopts_unix.go | 1 - pkg/socket/sockopts_unix1.go | 1 - pkg/socket/socktoaddr.go | 1 - pkg/socket/sys_cloexec.go | 1 - pkg/socket/tcp_socket.go | 1 - pkg/socket/udp_socket.go | 1 - pkg/socket/unix_socket.go | 1 - reactor_default.go | 2 - reactor_ultimate.go | 2 - 61 files changed, 181 insertions(+), 92 deletions(-) create mode 100644 pkg/netpoll/example_test.go diff --git a/acceptor_unix.go b/acceptor_unix.go index 80070bf95..07d1e103f 100644 --- a/acceptor_unix.go +++ b/acceptor_unix.go @@ -13,7 +13,6 @@ // limitations under the License. //go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd -// +build darwin dragonfly freebsd linux netbsd openbsd package gnet diff --git a/client_test.go b/client_test.go index e51b4fcd0..e83693070 100644 --- a/client_test.go +++ b/client_test.go @@ -1,5 +1,4 @@ //go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || windows -// +build darwin dragonfly freebsd linux netbsd openbsd windows package gnet diff --git a/client_unix.go b/client_unix.go index e8150217b..56de25411 100644 --- a/client_unix.go +++ b/client_unix.go @@ -13,7 +13,6 @@ // limitations under the License. //go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd -// +build darwin dragonfly freebsd linux netbsd openbsd package gnet diff --git a/conn_map.go b/conn_map.go index 6b1b02aa1..2a33edec8 100644 --- a/conn_map.go +++ b/conn_map.go @@ -13,8 +13,6 @@ // limitations under the License. //go:build (darwin || dragonfly || freebsd || linux || netbsd || openbsd) && !gc_opt -// +build darwin dragonfly freebsd linux netbsd openbsd -// +build !gc_opt package gnet diff --git a/conn_matrix.go b/conn_matrix.go index 6076a41fb..bc1791e06 100644 --- a/conn_matrix.go +++ b/conn_matrix.go @@ -13,8 +13,6 @@ // limitations under the License. //go:build (darwin || dragonfly || freebsd || linux || netbsd || openbsd) && gc_opt -// +build darwin dragonfly freebsd linux netbsd openbsd -// +build gc_opt package gnet diff --git a/conn_matrix_test.go b/conn_matrix_test.go index c13e39e83..4294d905d 100644 --- a/conn_matrix_test.go +++ b/conn_matrix_test.go @@ -1,6 +1,4 @@ //go:build (darwin || dragonfly || freebsd || linux || netbsd || openbsd) && gc_opt -// +build darwin dragonfly freebsd linux netbsd openbsd -// +build gc_opt package gnet diff --git a/connection_bsd.go b/connection_bsd.go index 29baa8fde..02fdbcfea 100644 --- a/connection_bsd.go +++ b/connection_bsd.go @@ -13,7 +13,6 @@ // limitations under the License. //go:build darwin || dragonfly || freebsd || netbsd || openbsd -// +build darwin dragonfly freebsd netbsd openbsd package gnet diff --git a/connection_unix.go b/connection_unix.go index ade55d836..ac669d4b5 100644 --- a/connection_unix.go +++ b/connection_unix.go @@ -13,7 +13,6 @@ // limitations under the License. //go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd -// +build darwin dragonfly freebsd linux netbsd openbsd package gnet diff --git a/engine_unix.go b/engine_unix.go index 8613af4a6..80a6e01ed 100644 --- a/engine_unix.go +++ b/engine_unix.go @@ -13,7 +13,6 @@ // limitations under the License. //go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd -// +build darwin dragonfly freebsd linux netbsd openbsd package gnet diff --git a/eventloop_unix.go b/eventloop_unix.go index a0cb77b69..2de88a219 100644 --- a/eventloop_unix.go +++ b/eventloop_unix.go @@ -13,7 +13,6 @@ // limitations under the License. //go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd -// +build darwin dragonfly freebsd linux netbsd openbsd package gnet diff --git a/eventloop_unix_test.go b/eventloop_unix_test.go index c166dde0a..43e54520e 100644 --- a/eventloop_unix_test.go +++ b/eventloop_unix_test.go @@ -1,5 +1,4 @@ //go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd -// +build darwin dragonfly freebsd linux netbsd openbsd package gnet diff --git a/listener_unix.go b/listener_unix.go index a339fbd3b..4dc20f191 100644 --- a/listener_unix.go +++ b/listener_unix.go @@ -13,7 +13,6 @@ // limitations under the License. //go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd -// +build darwin dragonfly freebsd linux netbsd openbsd package gnet diff --git a/os_unix_test.go b/os_unix_test.go index 2ff97ed11..1b100f9b4 100644 --- a/os_unix_test.go +++ b/os_unix_test.go @@ -1,5 +1,4 @@ //go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd -// +build darwin dragonfly freebsd linux netbsd openbsd package gnet diff --git a/os_windows_test.go b/os_windows_test.go index 99ec4eeb3..da7ada1cf 100644 --- a/os_windows_test.go +++ b/os_windows_test.go @@ -1,5 +1,4 @@ //go:build windows -// +build windows package gnet diff --git a/pkg/io/io_bsd.go b/pkg/io/io_bsd.go index c32109059..04178de6f 100644 --- a/pkg/io/io_bsd.go +++ b/pkg/io/io_bsd.go @@ -13,7 +13,6 @@ // limitations under the License. //go:build darwin || dragonfly || freebsd || netbsd || openbsd -// +build darwin dragonfly freebsd netbsd openbsd package io diff --git a/pkg/netpoll/defs_bsd_32bit.go b/pkg/netpoll/defs_bsd_32bit.go index 1a42c4a76..7f2bfded7 100644 --- a/pkg/netpoll/defs_bsd_32bit.go +++ b/pkg/netpoll/defs_bsd_32bit.go @@ -13,8 +13,6 @@ // limitations under the License. //go:build (darwin || dragonfly || freebsd || netbsd || openbsd) && (386 || arm || mips || mipsle) -// +build darwin dragonfly freebsd netbsd openbsd -// +build 386 arm mips mipsle package netpoll diff --git a/pkg/netpoll/defs_bsd_64bit.go b/pkg/netpoll/defs_bsd_64bit.go index 7248bcceb..f0c6be3ef 100644 --- a/pkg/netpoll/defs_bsd_64bit.go +++ b/pkg/netpoll/defs_bsd_64bit.go @@ -13,8 +13,6 @@ // limitations under the License. //go:build (darwin || dragonfly || freebsd || netbsd || openbsd) && (amd64 || arm64 || ppc64 || ppc64le || mips64 || mips64le || riscv64) -// +build darwin dragonfly freebsd netbsd openbsd -// +build amd64 arm64 ppc64 ppc64le mips64 mips64le riscv64 package netpoll diff --git a/pkg/netpoll/defs_linux.go b/pkg/netpoll/defs_linux.go index 91ea6e5ab..f1aed99a6 100644 --- a/pkg/netpoll/defs_linux.go +++ b/pkg/netpoll/defs_linux.go @@ -13,7 +13,6 @@ // limitations under the License. //go:build !poll_opt -// +build !poll_opt package netpoll diff --git a/pkg/netpoll/defs_linux_386.go b/pkg/netpoll/defs_linux_386.go index c8a2d5234..cf1edecb0 100644 --- a/pkg/netpoll/defs_linux_386.go +++ b/pkg/netpoll/defs_linux_386.go @@ -2,7 +2,6 @@ // cgo -cdefs defs2_linux.go //go:build poll_opt -// +build poll_opt package netpoll diff --git a/pkg/netpoll/defs_linux_amd64.go b/pkg/netpoll/defs_linux_amd64.go index 014ba2695..c50bde01a 100644 --- a/pkg/netpoll/defs_linux_amd64.go +++ b/pkg/netpoll/defs_linux_amd64.go @@ -2,7 +2,6 @@ // cgo -cdefs defs_linux.go defs1_linux.go //go:build poll_opt -// +build poll_opt package netpoll diff --git a/pkg/netpoll/defs_linux_arm.go b/pkg/netpoll/defs_linux_arm.go index 51178591b..60910aeb8 100644 --- a/pkg/netpoll/defs_linux_arm.go +++ b/pkg/netpoll/defs_linux_arm.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build poll_opt -// +build poll_opt package netpoll diff --git a/pkg/netpoll/defs_linux_arm64.go b/pkg/netpoll/defs_linux_arm64.go index f7c6d6e35..be531aff8 100644 --- a/pkg/netpoll/defs_linux_arm64.go +++ b/pkg/netpoll/defs_linux_arm64.go @@ -2,7 +2,6 @@ // ../cmd/cgo/cgo -cdefs defs_linux.go defs1_linux.go defs2_linux.go //go:build poll_opt -// +build poll_opt package netpoll diff --git a/pkg/netpoll/defs_linux_mips64x.go b/pkg/netpoll/defs_linux_mips64x.go index 3e8e93516..43a882b7c 100644 --- a/pkg/netpoll/defs_linux_mips64x.go +++ b/pkg/netpoll/defs_linux_mips64x.go @@ -3,9 +3,6 @@ // license that can be found in the LICENSE file. //go:build (mips64 || mips64le) && linux && poll_opt -// +build mips64 mips64le -// +build linux -// +build poll_opt package netpoll diff --git a/pkg/netpoll/defs_linux_mipsx.go b/pkg/netpoll/defs_linux_mipsx.go index 0b0fba1c2..383241348 100644 --- a/pkg/netpoll/defs_linux_mipsx.go +++ b/pkg/netpoll/defs_linux_mipsx.go @@ -3,9 +3,6 @@ // license that can be found in the LICENSE file. //go:build (mips || mipsle) && linux && poll_opt -// +build mips mipsle -// +build linux -// +build poll_opt package netpoll diff --git a/pkg/netpoll/defs_linux_ppc64.go b/pkg/netpoll/defs_linux_ppc64.go index 1a75dd889..30a37f377 100644 --- a/pkg/netpoll/defs_linux_ppc64.go +++ b/pkg/netpoll/defs_linux_ppc64.go @@ -2,7 +2,6 @@ // cgo -cdefs defs_linux.go defs3_linux.go //go:build poll_opt -// +build poll_opt package netpoll diff --git a/pkg/netpoll/defs_linux_ppc64le.go b/pkg/netpoll/defs_linux_ppc64le.go index 1a75dd889..30a37f377 100644 --- a/pkg/netpoll/defs_linux_ppc64le.go +++ b/pkg/netpoll/defs_linux_ppc64le.go @@ -2,7 +2,6 @@ // cgo -cdefs defs_linux.go defs3_linux.go //go:build poll_opt -// +build poll_opt package netpoll diff --git a/pkg/netpoll/defs_linux_riscv64.go b/pkg/netpoll/defs_linux_riscv64.go index cbe976a7f..162697da2 100644 --- a/pkg/netpoll/defs_linux_riscv64.go +++ b/pkg/netpoll/defs_linux_riscv64.go @@ -3,7 +3,6 @@ // go tool cgo -godefs defs_linux.go defs1_linux.go defs2_linux.go //go:build poll_opt -// +build poll_opt package netpoll diff --git a/pkg/netpoll/defs_linux_s390x.go b/pkg/netpoll/defs_linux_s390x.go index 9a6889888..120a9aac5 100644 --- a/pkg/netpoll/defs_linux_s390x.go +++ b/pkg/netpoll/defs_linux_s390x.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build poll_opt -// +build poll_opt package netpoll diff --git a/pkg/netpoll/defs_poller.go b/pkg/netpoll/defs_poller.go index ed12ca80d..f1b8bf199 100644 --- a/pkg/netpoll/defs_poller.go +++ b/pkg/netpoll/defs_poller.go @@ -13,7 +13,6 @@ // limitations under the License. //go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd -// +build darwin dragonfly freebsd linux netbsd openbsd package netpoll diff --git a/pkg/netpoll/defs_poller_bsd.go b/pkg/netpoll/defs_poller_bsd.go index 772e8e4e2..b778ad2a3 100644 --- a/pkg/netpoll/defs_poller_bsd.go +++ b/pkg/netpoll/defs_poller_bsd.go @@ -13,7 +13,6 @@ // limitations under the License. //go:build darwin || dragonfly || freebsd || openbsd -// +build darwin dragonfly freebsd openbsd package netpoll diff --git a/pkg/netpoll/defs_poller_epoll.go b/pkg/netpoll/defs_poller_epoll.go index 9a07206f7..6dbd031ce 100644 --- a/pkg/netpoll/defs_poller_epoll.go +++ b/pkg/netpoll/defs_poller_epoll.go @@ -13,7 +13,6 @@ // limitations under the License. //go:build linux -// +build linux package netpoll diff --git a/pkg/netpoll/defs_poller_kqueue.go b/pkg/netpoll/defs_poller_kqueue.go index 9ce5f520d..b92d690c5 100644 --- a/pkg/netpoll/defs_poller_kqueue.go +++ b/pkg/netpoll/defs_poller_kqueue.go @@ -13,7 +13,6 @@ // limitations under the License. //go:build darwin || dragonfly || freebsd || netbsd || openbsd -// +build darwin dragonfly freebsd netbsd openbsd package netpoll diff --git a/pkg/netpoll/example_test.go b/pkg/netpoll/example_test.go new file mode 100644 index 000000000..a984424f8 --- /dev/null +++ b/pkg/netpoll/example_test.go @@ -0,0 +1,155 @@ +// Copyright (c) 2025 The Gnet Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd + +package netpoll_test + +import ( + "context" + "fmt" + "net" + "os" + "os/signal" + "time" + + "github.com/panjf2000/gnet/v2/pkg/errors" + "github.com/panjf2000/gnet/v2/pkg/netpoll" +) + +func Example() { + ln, err := net.Listen("tcp", "127.0.0.1:9090") + if err != nil { + panic(fmt.Sprintf("Error listening: %v", err)) + } + + defer ln.Close() + + ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, os.Kill) + defer cancel() + + go func() { + c, err := ln.Accept() + if err != nil { + panic(fmt.Sprintf("Error accepting connection: %v", err)) + } + + defer c.Close() + + buf := make([]byte, 64) + + for { + select { + case <-ctx.Done(): + cancel() + fmt.Printf("Signal received: %v\n", ctx.Err()) + return + default: + } + + _, err := c.Read(buf) + if err != nil { + panic(fmt.Sprintf("Error reading data from client: %v", err)) + } + fmt.Printf("Received data from client: %s\n", buf) + + _, err = c.Write([]byte("Hello, client!")) + if err != nil { + panic(fmt.Sprintf("Error writing data to client: %v", err)) + } + fmt.Println("Sent data to client") + + time.Sleep(200 * time.Millisecond) + } + }() + + // Wait for the server to start running. + time.Sleep(500 * time.Millisecond) + + poller, err := netpoll.OpenPoller() + if err != nil { + panic(fmt.Sprintf("Error opening poller: %v", err)) + } + + defer poller.Close() + + addr, err := net.ResolveTCPAddr("tcp", ln.Addr().String()) + if err != nil { + panic(fmt.Sprintf("Error resolving TCP address: %v", err)) + } + c, err := net.DialTCP("tcp", nil, addr) + if err != nil { + panic(fmt.Sprintf("Error dialing TCP address: %v", err)) + } + + f, err := c.File() + if err != nil { + panic(fmt.Sprintf("Error getting file from connection: %v", err)) + } + + closeClient := func() { + c.Close() + f.Close() + } + defer closeClient() + + sendData := true + + pa := netpoll.PollAttachment{ + FD: int(f.Fd()), + Callback: func(fd int, event netpoll.IOEvent, flags netpoll.IOFlags) error { //nolint:revive + if netpoll.IsErrorEvent(event, flags) { + closeClient() + return errors.ErrEngineShutdown + } + + if netpoll.IsReadEvent(event) { + sendData = true + buf := make([]byte, 64) + _, err := c.Read(buf) + if err != nil { + closeClient() + fmt.Println("Error reading data from server:", err) + return errors.ErrEngineShutdown + } + fmt.Printf("Received data from server: %s\n", buf) + // Process the data... + } + + if netpoll.IsWriteEvent(event) && sendData { + sendData = false + // Write data to the connection... + _, err := c.Write([]byte("Hello, server!")) + if err != nil { + closeClient() + fmt.Println("Error writing data to server:", err) + return errors.ErrEngineShutdown + } + fmt.Println("Sent data to server") + } + + return nil + }, + } + + if err := poller.AddReadWrite(&pa, false); err != nil { + panic(fmt.Sprintf("Error adding file descriptor to poller: %v", err)) + } + + err = poller.Polling(func(fd int, event netpoll.IOEvent, flags netpoll.IOFlags) error { + return pa.Callback(fd, event, flags) + }) + + fmt.Printf("Poller exited with error: %v", err) +} diff --git a/pkg/netpoll/netpoll.go b/pkg/netpoll/netpoll.go index d192710d5..84c7931bc 100644 --- a/pkg/netpoll/netpoll.go +++ b/pkg/netpoll/netpoll.go @@ -1,18 +1,18 @@ -/* - * Copyright (c) 2025 The Gnet Authors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright (c) 2025 The Gnet Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd /* Package netpoll provides a portable event-driven interface for network I/O. @@ -52,14 +52,15 @@ The OpenPoller function creates a new Poller instance: c.Close() f.Close() } + defer closeClient() The PollAttachment consists of a file descriptor and its callback function. -PollAttachment is used to register a file descriptor with the Poller. +PollAttachment is used to register a file descriptor to Poller. The callback function is called when an event occurs on the file descriptor: pa := netpoll.PollAttachment{ FD: int(f.Fd()), - Callback: func(i int, event netpoll.IOEvent, flags netpoll.IOFlags) error { + Callback: func(fd int, event netpoll.IOEvent, flags netpoll.IOFlags) error { if netpoll.IsErrorEvent(event, flags) { closeClient() return errors.ErrEngineShutdown @@ -67,6 +68,7 @@ The callback function is called when an event occurs on the file descriptor: if netpoll.IsReadEvent(event) { buf := make([]byte, 64) + // Read data from the connection. _, err := c.Read(buf) if err != nil { closeClient() @@ -76,7 +78,7 @@ The callback function is called when an event occurs on the file descriptor: } if netpoll.IsWriteEvent(event) { - // Write data to the connection... + // Write data to the connection. _, err := c.Write([]byte("hello")) if err != nil { closeClient() @@ -97,5 +99,11 @@ waiting for I/O events to occur: poller.Polling(func(fd int, event netpoll.IOEvent, flags netpoll.IOFlags) error { return pa.Callback(fd, event, flags) }) + +Or + + poller.Polling() + +if you've enabled the build tag `poll_opt`. */ package netpoll diff --git a/pkg/netpoll/poller_epoll_default.go b/pkg/netpoll/poller_epoll_default.go index 1eadabf1d..1d3531135 100644 --- a/pkg/netpoll/poller_epoll_default.go +++ b/pkg/netpoll/poller_epoll_default.go @@ -14,7 +14,6 @@ // limitations under the License. //go:build linux && !poll_opt -// +build linux,!poll_opt package netpoll diff --git a/pkg/netpoll/poller_epoll_ultimate.go b/pkg/netpoll/poller_epoll_ultimate.go index d7dc3369c..b72369361 100644 --- a/pkg/netpoll/poller_epoll_ultimate.go +++ b/pkg/netpoll/poller_epoll_ultimate.go @@ -13,7 +13,6 @@ // limitations under the License. //go:build linux && poll_opt -// +build linux,poll_opt package netpoll diff --git a/pkg/netpoll/poller_kqueue_default.go b/pkg/netpoll/poller_kqueue_default.go index 00716e7b6..9d0c1b321 100644 --- a/pkg/netpoll/poller_kqueue_default.go +++ b/pkg/netpoll/poller_kqueue_default.go @@ -13,8 +13,6 @@ // limitations under the License. //go:build (darwin || dragonfly || freebsd || netbsd || openbsd) && !poll_opt -// +build darwin dragonfly freebsd netbsd openbsd -// +build !poll_opt package netpoll diff --git a/pkg/netpoll/poller_kqueue_ultimate.go b/pkg/netpoll/poller_kqueue_ultimate.go index fdfbb06ac..adbe38cee 100644 --- a/pkg/netpoll/poller_kqueue_ultimate.go +++ b/pkg/netpoll/poller_kqueue_ultimate.go @@ -13,8 +13,6 @@ // limitations under the License. //go:build (darwin || dragonfly || freebsd || netbsd || openbsd) && poll_opt -// +build darwin dragonfly freebsd netbsd openbsd -// +build poll_opt package netpoll diff --git a/pkg/netpoll/poller_kqueue_wakeup.go b/pkg/netpoll/poller_kqueue_wakeup.go index 2f9f93298..57624c4b0 100644 --- a/pkg/netpoll/poller_kqueue_wakeup.go +++ b/pkg/netpoll/poller_kqueue_wakeup.go @@ -13,7 +13,6 @@ // limitations under the License. //go:build darwin || dragonfly || freebsd -// +build darwin dragonfly freebsd package netpoll diff --git a/pkg/netpoll/poller_kqueue_wakeup1.go b/pkg/netpoll/poller_kqueue_wakeup1.go index 4505b5087..71da7c36f 100644 --- a/pkg/netpoll/poller_kqueue_wakeup1.go +++ b/pkg/netpoll/poller_kqueue_wakeup1.go @@ -13,7 +13,6 @@ // limitations under the License. //go:build netbsd || openbsd -// +build netbsd openbsd package netpoll diff --git a/pkg/netpoll/poller_unix_ultimate.go b/pkg/netpoll/poller_unix_ultimate.go index 7404e77bb..4a126847a 100644 --- a/pkg/netpoll/poller_unix_ultimate.go +++ b/pkg/netpoll/poller_unix_ultimate.go @@ -13,8 +13,6 @@ // limitations under the License. //go:build (darwin || dragonfly || freebsd || linux || netbsd || openbsd) && poll_opt -// +build darwin dragonfly freebsd linux netbsd openbsd -// +build poll_opt package netpoll diff --git a/pkg/netpoll/syscall_epoll_generic_linux.go b/pkg/netpoll/syscall_epoll_generic_linux.go index edc88bb1b..613e98cbe 100644 --- a/pkg/netpoll/syscall_epoll_generic_linux.go +++ b/pkg/netpoll/syscall_epoll_generic_linux.go @@ -13,7 +13,6 @@ // limitations under the License. //go:build !arm64 && !riscv64 && poll_opt -// +build !arm64,!riscv64,poll_opt package netpoll diff --git a/pkg/netpoll/syscall_epoll_linux.go b/pkg/netpoll/syscall_epoll_linux.go index 4b28ae70d..becac04d5 100644 --- a/pkg/netpoll/syscall_epoll_linux.go +++ b/pkg/netpoll/syscall_epoll_linux.go @@ -13,7 +13,6 @@ // limitations under the License. //go:build poll_opt -// +build poll_opt package netpoll diff --git a/pkg/netpoll/syscall_epoll_riscv64_arm64_linux.go b/pkg/netpoll/syscall_epoll_riscv64_arm64_linux.go index 7575d719a..dbac0b7b0 100644 --- a/pkg/netpoll/syscall_epoll_riscv64_arm64_linux.go +++ b/pkg/netpoll/syscall_epoll_riscv64_arm64_linux.go @@ -13,8 +13,6 @@ // limitations under the License. //go:build ((linux && arm64) || (linux && riscv64)) && poll_opt -// +build linux,arm64 linux,riscv64 -// +build poll_opt package netpoll diff --git a/pkg/netpoll/syscall_errors_linux.go b/pkg/netpoll/syscall_errors_linux.go index 0ffc45ebe..f7fda6d55 100644 --- a/pkg/netpoll/syscall_errors_linux.go +++ b/pkg/netpoll/syscall_errors_linux.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build poll_opt -// +build poll_opt package netpoll diff --git a/pkg/socket/fd_unix.go b/pkg/socket/fd_unix.go index 4c5e60efc..870ac1391 100644 --- a/pkg/socket/fd_unix.go +++ b/pkg/socket/fd_unix.go @@ -13,7 +13,6 @@ // limitations under the License. //go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd -// +build darwin dragonfly freebsd linux netbsd openbsd package socket diff --git a/pkg/socket/sock_bsd.go b/pkg/socket/sock_bsd.go index 9d97ef417..2627b2fff 100644 --- a/pkg/socket/sock_bsd.go +++ b/pkg/socket/sock_bsd.go @@ -14,7 +14,6 @@ // limitations under the License. //go:build darwin || dragonfly || freebsd || netbsd || openbsd -// +build darwin dragonfly freebsd netbsd openbsd package socket diff --git a/pkg/socket/sock_cloexec.go b/pkg/socket/sock_cloexec.go index 334ad0a3b..ead70d820 100644 --- a/pkg/socket/sock_cloexec.go +++ b/pkg/socket/sock_cloexec.go @@ -13,7 +13,6 @@ // limitations under the License. //go:build dragonfly || freebsd || linux -// +build dragonfly freebsd linux package socket diff --git a/pkg/socket/sock_posix.go b/pkg/socket/sock_posix.go index 8b7dd24c4..16ef698a7 100644 --- a/pkg/socket/sock_posix.go +++ b/pkg/socket/sock_posix.go @@ -14,7 +14,6 @@ // limitations under the License. //go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd -// +build darwin dragonfly freebsd linux netbsd openbsd package socket diff --git a/pkg/socket/socket.go b/pkg/socket/socket.go index e389c9f8e..6e41e2085 100644 --- a/pkg/socket/socket.go +++ b/pkg/socket/socket.go @@ -14,7 +14,6 @@ // limitations under the License. //go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd -// +build darwin dragonfly freebsd linux netbsd openbsd // Package socket provides some handy socket-related functions. package socket diff --git a/pkg/socket/sockopts_bsd.go b/pkg/socket/sockopts_bsd.go index 92b1b79ec..b88f3078c 100644 --- a/pkg/socket/sockopts_bsd.go +++ b/pkg/socket/sockopts_bsd.go @@ -13,7 +13,6 @@ // limitations under the License. //go:build dragonfly || freebsd || netbsd || openbsd -// +build dragonfly freebsd netbsd openbsd package socket diff --git a/pkg/socket/sockopts_posix.go b/pkg/socket/sockopts_posix.go index 5da7a7206..84c57572e 100644 --- a/pkg/socket/sockopts_posix.go +++ b/pkg/socket/sockopts_posix.go @@ -13,7 +13,6 @@ // limitations under the License. //go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd -// +build darwin dragonfly freebsd linux netbsd openbsd package socket diff --git a/pkg/socket/sockopts_unix.go b/pkg/socket/sockopts_unix.go index e5ef0059b..b72ce3465 100644 --- a/pkg/socket/sockopts_unix.go +++ b/pkg/socket/sockopts_unix.go @@ -13,7 +13,6 @@ // limitations under the License. //go:build dragonfly || freebsd || linux || netbsd -// +build dragonfly freebsd linux netbsd package socket diff --git a/pkg/socket/sockopts_unix1.go b/pkg/socket/sockopts_unix1.go index d4c666f95..27cc5cdc1 100644 --- a/pkg/socket/sockopts_unix1.go +++ b/pkg/socket/sockopts_unix1.go @@ -13,7 +13,6 @@ // limitations under the License. //go:build darwin || dragonfly || linux || netbsd || openbsd -// +build darwin dragonfly linux netbsd openbsd package socket diff --git a/pkg/socket/socktoaddr.go b/pkg/socket/socktoaddr.go index d9a997e83..daadf400b 100644 --- a/pkg/socket/socktoaddr.go +++ b/pkg/socket/socktoaddr.go @@ -13,7 +13,6 @@ // limitations under the License. //go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd -// +build darwin dragonfly freebsd linux netbsd openbsd package socket diff --git a/pkg/socket/sys_cloexec.go b/pkg/socket/sys_cloexec.go index abd4ee378..b77e94a15 100644 --- a/pkg/socket/sys_cloexec.go +++ b/pkg/socket/sys_cloexec.go @@ -13,7 +13,6 @@ // limitations under the License. //go:build darwin || netbsd || openbsd -// +build darwin netbsd openbsd package socket diff --git a/pkg/socket/tcp_socket.go b/pkg/socket/tcp_socket.go index 5ee6abb65..821b52f91 100644 --- a/pkg/socket/tcp_socket.go +++ b/pkg/socket/tcp_socket.go @@ -14,7 +14,6 @@ // limitations under the License. //go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd -// +build darwin dragonfly freebsd linux netbsd openbsd package socket diff --git a/pkg/socket/udp_socket.go b/pkg/socket/udp_socket.go index 28a221532..00591802a 100644 --- a/pkg/socket/udp_socket.go +++ b/pkg/socket/udp_socket.go @@ -14,7 +14,6 @@ // limitations under the License. //go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd -// +build darwin dragonfly freebsd linux netbsd openbsd package socket diff --git a/pkg/socket/unix_socket.go b/pkg/socket/unix_socket.go index 992ded2b8..42375446d 100644 --- a/pkg/socket/unix_socket.go +++ b/pkg/socket/unix_socket.go @@ -13,7 +13,6 @@ // limitations under the License. //go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd -// +build darwin dragonfly freebsd linux netbsd openbsd package socket diff --git a/reactor_default.go b/reactor_default.go index ea468a4ff..1c737e39f 100644 --- a/reactor_default.go +++ b/reactor_default.go @@ -13,8 +13,6 @@ // limitations under the License. //go:build (darwin || dragonfly || freebsd || linux || netbsd || openbsd) && !poll_opt -// +build darwin dragonfly freebsd linux netbsd openbsd -// +build !poll_opt package gnet diff --git a/reactor_ultimate.go b/reactor_ultimate.go index ce307f7c1..55199bb7e 100644 --- a/reactor_ultimate.go +++ b/reactor_ultimate.go @@ -13,8 +13,6 @@ // limitations under the License. //go:build (darwin || dragonfly || freebsd || linux || netbsd || openbsd) && poll_opt -// +build darwin dragonfly freebsd linux netbsd openbsd -// +build poll_opt package gnet