From 7a77e9a84ddccf541739f650f0fab99d4e827a22 Mon Sep 17 00:00:00 2001 From: Aoang Date: Fri, 18 Mar 2022 11:54:44 +0800 Subject: [PATCH 1/7] Add Go 1.18 support --- .github/workflows/lint.yml | 2 +- .github/workflows/security.yml | 2 +- .github/workflows/test.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 5130b05f24..f2d4f8142d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -11,7 +11,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-go@v2 with: - go-version: 1.17.x + go-version: 1.18.x - run: go version - run: diff -u <(echo -n) <(gofmt -d .) - uses: golangci/golangci-lint-action@v2 diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml index 13b8fa76af..1a37f1de38 100644 --- a/.github/workflows/security.yml +++ b/.github/workflows/security.yml @@ -8,7 +8,7 @@ jobs: test: strategy: matrix: - go-version: [1.17.x] + go-version: [1.18.x] platform: [ubuntu-latest] runs-on: ${{ matrix.platform }} steps: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 068a6f5cd0..429c155418 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,7 +8,7 @@ jobs: test: strategy: matrix: - go-version: [1.15.x, 1.16.x, 1.17.x] + go-version: [1.15.x, 1.16.x, 1.17.x, 1.18.x] os: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.os }} steps: From 4657a76f0fd104ac1bd2eda2e7f269bdd8305421 Mon Sep 17 00:00:00 2001 From: Aoang Date: Fri, 18 Mar 2022 12:10:43 +0800 Subject: [PATCH 2/7] fix Gosec Security Scanner https://github.com/valyala/fasthttp/runs/5595618634?check_suite_focus=true --- .github/workflows/security.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml index 1a37f1de38..4e493ea5f2 100644 --- a/.github/workflows/security.yml +++ b/.github/workflows/security.yml @@ -11,6 +11,8 @@ jobs: go-version: [1.18.x] platform: [ubuntu-latest] runs-on: ${{ matrix.platform }} + env: + GO111MODULE: on steps: - name: Install Go uses: actions/setup-go@v1 @@ -18,5 +20,7 @@ jobs: go-version: ${{ matrix.go-version }} - name: Checkout code uses: actions/checkout@v2 - - name: Security - run: go get github.com/securego/gosec/cmd/gosec; `go env GOPATH`/bin/gosec -exclude=G104,G304 ./... + - name: Run Gosec Security Scanner + uses: securego/gosec@master + with: + args: -exclude=G104,G304 ./... From a9170032f5d599bd47bf36b59f45eaac6d10e5af Mon Sep 17 00:00:00 2001 From: Aoang Date: Fri, 18 Mar 2022 12:24:14 +0800 Subject: [PATCH 3/7] fix https://github.com/securego/gosec/issues/469#issuecomment-1070608395 Gosec Github Action Doesn't Work at Go 1.18 --- .github/workflows/security.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml index 4e493ea5f2..15f6ab12cd 100644 --- a/.github/workflows/security.yml +++ b/.github/workflows/security.yml @@ -21,6 +21,7 @@ jobs: - name: Checkout code uses: actions/checkout@v2 - name: Run Gosec Security Scanner - uses: securego/gosec@master - with: - args: -exclude=G104,G304 ./... + run: | # https://github.com/securego/gosec/issues/469#issuecomment-1070608395 + export PATH=$PATH:$(go env GOPATH)/bin + go install github.com/securego/gosec/v2/cmd/gosec@latest + gosec -exclude=G104,G304 ./... From 97effd4418d36f163cc81e7ff55c1634579780fd Mon Sep 17 00:00:00 2001 From: Aoang Date: Fri, 18 Mar 2022 14:14:32 +0800 Subject: [PATCH 4/7] fix https://github.com/golangci/golangci-lint/pull/2438 golangci/golangci-lint Doesn't Work at Go 1.18 --- .github/workflows/lint.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index f2d4f8142d..6c2c7b0546 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -14,6 +14,9 @@ jobs: go-version: 1.18.x - run: go version - run: diff -u <(echo -n) <(gofmt -d .) - - uses: golangci/golangci-lint-action@v2 - with: - version: v1.28.3 + - name: Run golangci-lint + run: | # https://github.com/golangci/golangci-lint/pull/2438 + export PATH=$PATH:$(go env GOPATH)/bin + go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.44.2 + golangci-lint run + From 864f7c51a078b29d7409f657c73ffb7c9992cb6d Mon Sep 17 00:00:00 2001 From: Aoang Date: Fri, 18 Mar 2022 14:32:20 +0800 Subject: [PATCH 5/7] fix golint unused --- nocopy.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nocopy.go b/nocopy.go index 9664cb06b6..5e41bdf40d 100644 --- a/nocopy.go +++ b/nocopy.go @@ -7,5 +7,5 @@ package fasthttp // and also: https://stackoverflow.com/questions/52494458/nocopy-minimal-example type noCopy struct{} //nolint:unused -func (*noCopy) Lock() {} -func (*noCopy) Unlock() {} +func (*noCopy) Lock() {} //nolint:unused +func (*noCopy) Unlock() {} //nolint:unused From 6daf5b1cad2ea403f968d61e0410e5562a37fa06 Mon Sep 17 00:00:00 2001 From: Aoang Date: Fri, 18 Mar 2022 14:35:17 +0800 Subject: [PATCH 6/7] fix golint: SA1019: netErr.Temporary is deprecated --- client.go | 4 ++-- server.go | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/client.go b/client.go index e3173bebf3..874dbca1f3 100644 --- a/client.go +++ b/client.go @@ -2631,8 +2631,8 @@ func (c *pipelineConnClient) init() { for { if err := c.worker(); err != nil { c.logger().Printf("error in PipelineClient(%q): %s", c.Addr, err) - if netErr, ok := err.(net.Error); ok && netErr.Temporary() { - // Throttle client reconnections on temporary errors + if netErr, ok := err.(net.Error); ok && netErr.Timeout() { + // Throttle client reconnections on timeout errors time.Sleep(time.Second) } } else { diff --git a/server.go b/server.go index 3b585422d9..3ff678ce02 100644 --- a/server.go +++ b/server.go @@ -482,7 +482,7 @@ func TimeoutWithCodeHandler(h RequestHandler, timeout time.Duration, msg string, } } -//RequestConfig configure the per request deadline and body limits +// RequestConfig configure the per request deadline and body limits type RequestConfig struct { // ReadTimeout is the maximum duration for reading the entire // request body. @@ -1915,8 +1915,8 @@ func acceptConn(s *Server, ln net.Listener, lastPerIPErrorTime *time.Time) (net. if c != nil { panic("BUG: net.Listener returned non-nil conn and non-nil error") } - if netErr, ok := err.(net.Error); ok && netErr.Temporary() { - s.logger().Printf("Temporary error when accepting new connections: %s", netErr) + if netErr, ok := err.(net.Error); ok && netErr.Timeout() { + s.logger().Printf("Timeout error when accepting new connections: %s", netErr) time.Sleep(time.Second) continue } @@ -2230,7 +2230,7 @@ func (s *Server) serveConn(c net.Conn) (err error) { writeTimeout = reqConf.WriteTimeout } } - //read body + // read body if s.StreamRequestBody { err = ctx.Request.readBodyStream(br, maxRequestBodySize, s.GetOnly, !s.DisablePreParseMultipartForm) } else { From 1f7bf09af70c81b71f6768bff41faee5b638172f Mon Sep 17 00:00:00 2001 From: Aoang Date: Fri, 18 Mar 2022 18:05:24 +0800 Subject: [PATCH 7/7] fix https://github.com/valyala/fasthttp/issues/1256 --- .github/workflows/security.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml index 15f6ab12cd..07c61ed57e 100644 --- a/.github/workflows/security.yml +++ b/.github/workflows/security.yml @@ -24,4 +24,4 @@ jobs: run: | # https://github.com/securego/gosec/issues/469#issuecomment-1070608395 export PATH=$PATH:$(go env GOPATH)/bin go install github.com/securego/gosec/v2/cmd/gosec@latest - gosec -exclude=G104,G304 ./... + gosec -exclude=G104,G304,G402 ./...