]> 127.0.0.1 Git - forward/.git/commitdiff
1
authorqydysky <qydysky@foxmail.com>
Sun, 14 Apr 2024 03:46:21 +0000 (03:46 +0000)
committerqydysky <qydysky@foxmail.com>
Sun, 14 Apr 2024 03:46:21 +0000 (03:46 +0000)
main.go
main_test.go

diff --git a/main.go b/main.go
index 3dd6a7ca82bddce5e8a8e22c9c0c883456c8ce15..f73a5d21406ea6fa01dac4e773dd9d5f32bcec9f 100755 (executable)
--- a/main.go
+++ b/main.go
@@ -48,7 +48,9 @@ func main() {
                msdChan, wait := dealConfig(ctx, config)
 
                defer wait()
-               defer pctx.CallCancel(ctx)
+               defer func() {
+                       _ = pctx.CallCancel(ctx)
+               }()
 
                for {
                        select {
@@ -94,7 +96,9 @@ func dealConfig(ctx context.Context, config Config) (msgChan chan ConfigMsg, Wai
                                <-ctx.Done()
                                close()
                        }()
-                       defer pctx.CallCancel(ctx)
+                       defer func() {
+                               _ = pctx.CallCancel(ctx)
+                       }()
 
                        for {
                                select {
index 19a2e4e261df8ab2bc16c3862514d4695529a5b4..d0368a85c6b92ea5f6af9e41f1b5bf56f4a40184 100755 (executable)
@@ -70,7 +70,9 @@ func Test(t *testing.T) {
                }
        }()
        defer wait()
-       defer pctx.CallCancel(ctx)
+       defer func() {
+               _ = pctx.CallCancel(ctx)
+       }()
 
        time.Sleep(time.Second)
        if e := tcpSer("127.0.0.1:20000", "127.0.0.1:20001"); e != nil {
@@ -131,7 +133,7 @@ func tcpSer(lis, to string) error {
                        // Print the data read from the connection to the terminal
 
                        // Write back the same message to the client
-                       conn.Write([]byte("Hello TCP Client\n"))
+                       _, _ = conn.Write([]byte("Hello TCP Client\n"))
                }()
        }
 
@@ -218,10 +220,10 @@ func udpSer(lis, to string) error {
                return err
        }
 
-       conn1.WriteToUDP([]byte("Hello UDP Server\n"), udpAddr)
+       _, _ = conn1.WriteToUDP([]byte("Hello UDP Server\n"), udpAddr)
 
        var buf [512]byte
-       conn1.SetDeadline(time.Now().Add(time.Second))
+       _ = conn1.SetDeadline(time.Now().Add(time.Second))
        n, _, err := conn1.ReadFromUDP(buf[0:])
        if err != nil {
                return err
@@ -231,8 +233,8 @@ func udpSer(lis, to string) error {
                return errors.New("no match:" + string(buf[:n]))
        }
 
-       conn1.WriteToUDP([]byte("Hello UDP Server\n"), udpAddr)
-       conn1.SetDeadline(time.Now().Add(time.Second))
+       _, _ = conn1.WriteToUDP([]byte("Hello UDP Server\n"), udpAddr)
+       _ = conn1.SetDeadline(time.Now().Add(time.Second))
        n, _, err = conn1.ReadFromUDP(buf[0:])
        if err != nil {
                return err
@@ -286,7 +288,7 @@ func udp2tcpSer(lis, to string) error {
                        // Print the data read from the connection to the terminal
 
                        // Write back the same message to the client
-                       conn.Write([]byte("Hello TCP Client\n"))
+                       _, _ = conn.Write([]byte("Hello TCP Client\n"))
                }()
        }
 
@@ -302,10 +304,10 @@ func udp2tcpSer(lis, to string) error {
                return err
        }
 
-       conn1.WriteToUDP([]byte("Hello UDP Server\n"), udpAddr)
+       _, _ = conn1.WriteToUDP([]byte("Hello UDP Server\n"), udpAddr)
 
        var buf [512]byte
-       conn1.SetDeadline(time.Now().Add(time.Second))
+       _ = conn1.SetDeadline(time.Now().Add(time.Second))
        n, _, err := conn1.ReadFromUDP(buf[0:])
        if err != nil {
                return err
@@ -351,7 +353,7 @@ func tcp2udpSer(lis, to string) error {
                        // Print the data read from the connection to the terminal
 
                        // Write back the same message to the client
-                       conn.Write([]byte("Hello UDP Client\n"))
+                       _, _ = conn.Write([]byte("Hello UDP Client\n"))
                }()
        }