diff --git a/.golangci.yml b/.golangci.yml index ad75ddf96d..225e24be6b 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -45,8 +45,6 @@ linters: - unparam - usestdlibvars - varnamelen - - wastedassign - - whitespace - wrapcheck - wsl diff --git a/args.go b/args.go index 9cc11067f5..1a1429c48d 100644 --- a/args.go +++ b/args.go @@ -551,7 +551,7 @@ func decodeArgAppend(dst, src []byte) []byte { return append(dst, src...) } - idx := 0 + var idx int switch { case idxPercent == -1: idx = idxPlus diff --git a/server.go b/server.go index 9cfc17534c..4bfa0c5d07 100644 --- a/server.go +++ b/server.go @@ -1780,8 +1780,6 @@ const DefaultConcurrency = 256 * 1024 func (s *Server) Serve(ln net.Listener) error { var lastOverflowErrorTime time.Time var lastPerIPErrorTime time.Time - var c net.Conn - var err error maxWorkersCount := s.getConcurrency() @@ -1813,7 +1811,8 @@ func (s *Server) Serve(ln net.Listener) error { defer atomic.AddInt32(&s.open, -1) for { - if c, err = acceptConn(s, ln, &lastPerIPErrorTime); err != nil { + c, err := acceptConn(s, ln, &lastPerIPErrorTime) + if err != nil { wp.Stop() if err == io.EOF { return nil @@ -1846,7 +1845,6 @@ func (s *Server) Serve(ln net.Listener) error { time.Sleep(s.SleepWhenConcurrencyLimitsExceeded) } } - c = nil } } @@ -2292,7 +2290,6 @@ func (s *Server) serveConn(c net.Conn) (err error) { // 'Expect: 100-continue' request handling. // See https://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html#sec8.2.3 for details. if ctx.Request.MayContinue() { - // Allow the ability to deny reading the incoming request body if s.ContinueHandler != nil { if continueReadingRequest = s.ContinueHandler(&ctx.Request.Header); !continueReadingRequest { @@ -2582,7 +2579,7 @@ func acquireByteReader(ctxP **RequestCtx) (*bufio.Reader, error) { c := ctx.c s.releaseCtx(ctx) - // Make GC happy, so it could garbage collect ctx while we wait for the + //nolint:wastedassign // Make GC happy, so it could garbage collect ctx while we wait for the // next request. ctx = nil *ctxP = nil diff --git a/server_test.go b/server_test.go index ad188db190..5bc7d80f91 100644 --- a/server_test.go +++ b/server_test.go @@ -1920,7 +1920,6 @@ func TestServerContinueHandler(t *testing.T) { // Expect 100 continue denied rw := &readWriter{} for i := 0; i < 25; i++ { - // Regular requests without Expect 100 continue header rw.r.Reset() rw.r.WriteString("POST /foo HTTP/1.1\r\nHost: gle.com\r\nContent-Length: 5\r\nContent-Type: a/b\r\n\r\n12345") diff --git a/streaming_test.go b/streaming_test.go index 084710b4da..e6ebb7c230 100644 --- a/streaming_test.go +++ b/streaming_test.go @@ -31,7 +31,7 @@ aaaaaaaaaa` s := &Server{ StreamRequestBody: true, Handler: func(ctx *RequestCtx) { - body := "" + var body string expected := "aaaaaaaaaa" if string(ctx.Path()) == "/one" { body = string(ctx.PostBody()) diff --git a/tcpdialer.go b/tcpdialer.go index 5c7531e948..a8538b803c 100644 --- a/tcpdialer.go +++ b/tcpdialer.go @@ -375,7 +375,6 @@ func (d *TCPDialer) tcpAddrsClean() { } return true }) - } } diff --git a/workerpool.go b/workerpool.go index 71da1f2f9a..12bc745a46 100644 --- a/workerpool.go +++ b/workerpool.go @@ -110,9 +110,9 @@ func (wp *workerPool) clean(scratch *[]*workerChan) { n := len(ready) // Use binary-search algorithm to find out the index of the least recently worker which can be cleaned up. - l, r, mid := 0, n-1, 0 + l, r := 0, n-1 for l <= r { - mid = (l + r) / 2 + mid := (l + r) / 2 if criticalTime.After(wp.ready[mid].lastUseTime) { l = mid + 1 } else { @@ -238,7 +238,6 @@ func (wp *workerPool) workerFunc(ch *workerChan) { _ = c.Close() wp.connState(c, StateClosed) } - c = nil if !wp.release(ch) { break