Skip to content

Commit f3bce3a

Browse files
authored
Add Go 1.18 support (#1253)
* 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 #1256
1 parent c674263 commit f3bce3a

File tree

6 files changed

+24
-16
lines changed

6 files changed

+24
-16
lines changed

.github/workflows/lint.yml

+7-4
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@ jobs:
1111
- uses: actions/checkout@v2
1212
- uses: actions/setup-go@v2
1313
with:
14-
go-version: 1.17.x
14+
go-version: 1.18.x
1515
- run: go version
1616
- run: diff -u <(echo -n) <(gofmt -d .)
17-
- uses: golangci/golangci-lint-action@v2
18-
with:
19-
version: v1.28.3
17+
- name: Run golangci-lint
18+
run: | # https://github.com/golangci/golangci-lint/pull/2438
19+
export PATH=$PATH:$(go env GOPATH)/bin
20+
go install github.com/golangci/golangci-lint/cmd/[email protected]
21+
golangci-lint run
22+

.github/workflows/security.yml

+8-3
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,20 @@ jobs:
88
test:
99
strategy:
1010
matrix:
11-
go-version: [1.17.x]
11+
go-version: [1.18.x]
1212
platform: [ubuntu-latest]
1313
runs-on: ${{ matrix.platform }}
14+
env:
15+
GO111MODULE: on
1416
steps:
1517
- name: Install Go
1618
uses: actions/setup-go@v1
1719
with:
1820
go-version: ${{ matrix.go-version }}
1921
- name: Checkout code
2022
uses: actions/checkout@v2
21-
- name: Security
22-
run: go get github.com/securego/gosec/cmd/gosec; `go env GOPATH`/bin/gosec -exclude=G104,G304 ./...
23+
- name: Run Gosec Security Scanner
24+
run: | # https://github.com/securego/gosec/issues/469#issuecomment-1070608395
25+
export PATH=$PATH:$(go env GOPATH)/bin
26+
go install github.com/securego/gosec/v2/cmd/gosec@latest
27+
gosec -exclude=G104,G304,G402 ./...

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
test:
99
strategy:
1010
matrix:
11-
go-version: [1.15.x, 1.16.x, 1.17.x]
11+
go-version: [1.15.x, 1.16.x, 1.17.x, 1.18.x]
1212
os: [ubuntu-latest, macos-latest, windows-latest]
1313
runs-on: ${{ matrix.os }}
1414
steps:

client.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -2631,8 +2631,8 @@ func (c *pipelineConnClient) init() {
26312631
for {
26322632
if err := c.worker(); err != nil {
26332633
c.logger().Printf("error in PipelineClient(%q): %s", c.Addr, err)
2634-
if netErr, ok := err.(net.Error); ok && netErr.Temporary() {
2635-
// Throttle client reconnections on temporary errors
2634+
if netErr, ok := err.(net.Error); ok && netErr.Timeout() {
2635+
// Throttle client reconnections on timeout errors
26362636
time.Sleep(time.Second)
26372637
}
26382638
} else {

nocopy.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ package fasthttp
77
// and also: https://stackoverflow.com/questions/52494458/nocopy-minimal-example
88
type noCopy struct{} //nolint:unused
99

10-
func (*noCopy) Lock() {}
11-
func (*noCopy) Unlock() {}
10+
func (*noCopy) Lock() {} //nolint:unused
11+
func (*noCopy) Unlock() {} //nolint:unused

server.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ func TimeoutWithCodeHandler(h RequestHandler, timeout time.Duration, msg string,
482482
}
483483
}
484484

485-
//RequestConfig configure the per request deadline and body limits
485+
// RequestConfig configure the per request deadline and body limits
486486
type RequestConfig struct {
487487
// ReadTimeout is the maximum duration for reading the entire
488488
// request body.
@@ -1915,8 +1915,8 @@ func acceptConn(s *Server, ln net.Listener, lastPerIPErrorTime *time.Time) (net.
19151915
if c != nil {
19161916
panic("BUG: net.Listener returned non-nil conn and non-nil error")
19171917
}
1918-
if netErr, ok := err.(net.Error); ok && netErr.Temporary() {
1919-
s.logger().Printf("Temporary error when accepting new connections: %s", netErr)
1918+
if netErr, ok := err.(net.Error); ok && netErr.Timeout() {
1919+
s.logger().Printf("Timeout error when accepting new connections: %s", netErr)
19201920
time.Sleep(time.Second)
19211921
continue
19221922
}
@@ -2230,7 +2230,7 @@ func (s *Server) serveConn(c net.Conn) (err error) {
22302230
writeTimeout = reqConf.WriteTimeout
22312231
}
22322232
}
2233-
//read body
2233+
// read body
22342234
if s.StreamRequestBody {
22352235
err = ctx.Request.readBodyStream(br, maxRequestBodySize, s.GetOnly, !s.DisablePreParseMultipartForm)
22362236
} else {

0 commit comments

Comments
 (0)