Skip to content

Commit

Permalink
Add Go 1.18 support (valyala#1253)
Browse files Browse the repository at this point in the history
* Add Go 1.18 support

* fix Gosec Security Scanner

https://github.com/valyala/fasthttp/runs/5595618634?check_suite_focus=true

* fix securego/gosec#469 (comment) Gosec Github Action Doesn't Work at Go 1.18

* fix golangci/golangci-lint#2438 golangci/golangci-lint Doesn't Work at Go 1.18

* fix golint unused

* fix golint: SA1019: netErr.Temporary is deprecated

* fix valyala#1256
  • Loading branch information
Aoang authored and u5surf committed Mar 23, 2022
1 parent a8fea75 commit 4d07b0f
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 16 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ 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
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
11 changes: 8 additions & 3 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,20 @@ jobs:
test:
strategy:
matrix:
go-version: [1.17.x]
go-version: [1.18.x]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
env:
GO111MODULE: on
steps:
- name: Install Go
uses: actions/setup-go@v1
with:
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
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,G402 ./...
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions nocopy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -1918,8 +1918,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
}
Expand Down Expand Up @@ -2236,7 +2236,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 {
Expand Down

0 comments on commit 4d07b0f

Please sign in to comment.