Fix golangci-lint v2 compliance, make all passes clean
- Fix 314 errcheck violations (blank identifier for unrecoverable errors) - Fix errorlint violation (errors.Is for io.EOF) - Remove unused serveL7Route test helper - Simplify Duration.Seconds() selectors in tests - Remove unnecessary fmt.Sprintf in test - Migrate exclusion rules from issues.exclusions to linters.exclusions (v2 schema) - Add gosec test exclusions (G115, G304, G402, G705) - Disable fieldalignment govet analyzer (optimization, not correctness) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@ package proxy
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
"net"
|
||||
"sync"
|
||||
@@ -31,8 +32,8 @@ func Relay(ctx context.Context, client, backend net.Conn, peeked []byte, idleTim
|
||||
|
||||
go func() {
|
||||
<-ctx.Done()
|
||||
client.Close()
|
||||
backend.Close()
|
||||
_ = client.Close()
|
||||
_ = backend.Close()
|
||||
}()
|
||||
|
||||
var (
|
||||
@@ -50,7 +51,7 @@ func Relay(ctx context.Context, client, backend net.Conn, peeked []byte, idleTim
|
||||
result.ClientBytes, errC2B = copyWithIdleTimeout(backend, client, idleTimeout)
|
||||
// Half-close backend's write side.
|
||||
if hc, ok := backend.(interface{ CloseWrite() error }); ok {
|
||||
hc.CloseWrite()
|
||||
_ = hc.CloseWrite()
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -60,7 +61,7 @@ func Relay(ctx context.Context, client, backend net.Conn, peeked []byte, idleTim
|
||||
result.BackendBytes, errB2C = copyWithIdleTimeout(client, backend, idleTimeout)
|
||||
// Half-close client's write side.
|
||||
if hc, ok := client.(interface{ CloseWrite() error }); ok {
|
||||
hc.CloseWrite()
|
||||
_ = hc.CloseWrite()
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -85,10 +86,10 @@ func copyWithIdleTimeout(dst, src net.Conn, idleTimeout time.Duration) (int64, e
|
||||
var total int64
|
||||
|
||||
for {
|
||||
src.SetReadDeadline(time.Now().Add(idleTimeout))
|
||||
_ = src.SetReadDeadline(time.Now().Add(idleTimeout))
|
||||
nr, readErr := src.Read(buf)
|
||||
if nr > 0 {
|
||||
dst.SetWriteDeadline(time.Now().Add(idleTimeout))
|
||||
_ = dst.SetWriteDeadline(time.Now().Add(idleTimeout))
|
||||
nw, writeErr := dst.Write(buf[:nr])
|
||||
total += int64(nw)
|
||||
if writeErr != nil {
|
||||
@@ -96,7 +97,7 @@ func copyWithIdleTimeout(dst, src net.Conn, idleTimeout time.Duration) (int64, e
|
||||
}
|
||||
}
|
||||
if readErr != nil {
|
||||
if readErr == io.EOF {
|
||||
if errors.Is(readErr, io.EOF) {
|
||||
return total, nil
|
||||
}
|
||||
return total, readErr
|
||||
|
||||
Reference in New Issue
Block a user