Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable wastedassign, whitespace linters; fix issues #1665

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ linters:
- unparam
- usestdlibvars
- varnamelen
- wastedassign
- whitespace
- wrapcheck
- wsl

Expand Down
2 changes: 1 addition & 1 deletion args.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 3 additions & 6 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1846,7 +1845,6 @@ func (s *Server) Serve(ln net.Listener) error {
time.Sleep(s.SleepWhenConcurrencyLimitsExceeded)
}
}
c = nil
}
}

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion streaming_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
1 change: 0 additions & 1 deletion tcpdialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,6 @@ func (d *TCPDialer) tcpAddrsClean() {
}
return true
})

}
}

Expand Down
5 changes: 2 additions & 3 deletions workerpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -238,7 +238,6 @@ func (wp *workerPool) workerFunc(ch *workerChan) {
_ = c.Close()
wp.connState(c, StateClosed)
}
c = nil
alexandear marked this conversation as resolved.
Show resolved Hide resolved

if !wp.release(ch) {
break
Expand Down
Loading