Skip to content

Commit ea60524

Browse files
authored
Add Go 1.19 Support (#1355)
* Update Go Version to Go1.19.x And add cache * Fix CI Line endings * Update test CI Go Version to Go1.19.x And add cache * Update Gosec Security Scanner CI to securego/gosec@v2.12.0 * Format comment Go 1.19 adds support for links, lists, and clearer headings in doc comments. As part of this change, gofmt now reformats doc comments to make their rendered meaning clearer. See “Go Doc Comments” for syntax details and descriptions of common mistakes now highlighted by gofmt. As another part of this change, the new package go/doc/comment provides parsing and reformatting of doc comments as well as support for rendering them to HTML, Markdown, and text. ref: https://tip.golang.org/doc/go1.19 ref: https://tip.golang.org/doc/comment * Fix doc structure
1 parent a5f448f commit ea60524

File tree

20 files changed

+342
-288
lines changed

20 files changed

+342
-288
lines changed

.github/workflows/lint.yml

+33-7
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,40 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- uses: actions/checkout@v2
12-
- uses: actions/setup-go@v2
12+
- uses: actions/setup-go@v3
1313
with:
14-
go-version: 1.18.x
14+
go-version: 1.19.x
15+
16+
- name: Get Go cache paths
17+
id: go-env
18+
run: |
19+
echo "::set-output name=cache::$(go env GOCACHE)"
20+
echo "::set-output name=modcache::$(go env GOMODCACHE)"
21+
- name: Set up Go cache
22+
uses: actions/cache@v3
23+
with:
24+
key: golangci-lint-${{ runner.os }}-go-${{ hashFiles('go.mod') }}
25+
restore-keys: golangci-lint-${{ runner.os }}-go-
26+
path: |
27+
${{ steps.go-env.outputs.cache }}
28+
${{ steps.go-env.outputs.modcache }}
29+
30+
- name: Install golangci-lint
31+
run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.48.0
32+
33+
- name: Get golangci-lint cache path
34+
id: golangci-lint-cache-status
35+
run: |
36+
echo "::set-output name=dir::$(golangci-lint cache status | head -1 | sed 's/^Dir: //')"
37+
38+
- name: Set up golangci-lint cache
39+
uses: actions/cache@v3
40+
with:
41+
key: golangci-lint-${{ runner.os }}-golangci-lint-${{ hashFiles('go.mod') }}
42+
restore-keys: golangci-lint-${{ runner.os }}-golangci-lint-
43+
path: ${{ steps.golangci-lint-cache-status.outputs.dir }}
44+
1545
- run: go version
1646
- run: diff -u <(echo -n) <(gofmt -d .)
1747
- 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/golangci-lint@v1.44.2
21-
golangci-lint run
22-
48+
run: golangci-lint run

.github/workflows/security.yml

+5-11
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,14 @@ jobs:
88
test:
99
strategy:
1010
matrix:
11-
go-version: [1.18.x]
11+
go-version: [1.19.x]
1212
platform: [ubuntu-latest]
1313
runs-on: ${{ matrix.platform }}
1414
env:
1515
GO111MODULE: on
1616
steps:
17-
- name: Install Go
18-
uses: actions/setup-go@v1
19-
with:
20-
go-version: ${{ matrix.go-version }}
21-
- name: Checkout code
22-
uses: actions/checkout@v2
17+
- uses: actions/checkout@v2
2318
- 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 ./...
19+
uses: securego/gosec@v2.12.0
20+
with:
21+
args: '-exclude=G104,G304,G402 ./...'

.github/workflows/test.yml

+17-2
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,29 @@ jobs:
88
test:
99
strategy:
1010
matrix:
11-
go-version: [1.15.x, 1.16.x, 1.17.x, 1.18.x]
11+
go-version: [1.15.x, 1.16.x, 1.17.x, 1.18.x, 1.19.x]
1212
os: [ubuntu-latest, macos-latest, windows-latest]
1313
runs-on: ${{ matrix.os }}
1414
steps:
1515
- uses: actions/checkout@v2
16-
- uses: actions/setup-go@v2
16+
- uses: actions/setup-go@v3
1717
with:
1818
go-version: ${{ matrix.go-version }}
19+
20+
- name: Get Go cache paths
21+
id: go-env
22+
run: |
23+
echo "::set-output name=cache::$(go env GOCACHE)"
24+
echo "::set-output name=modcache::$(go env GOMODCACHE)"
25+
- name: Set up Go cache
26+
uses: actions/cache@v3
27+
with:
28+
key: golangci-lint-${{ runner.os }}-go-${{ hashFiles('go.mod') }}
29+
restore-keys: golangci-lint-${{ runner.os }}-go-
30+
path: |
31+
${{ steps.go-env.outputs.cache }}
32+
${{ steps.go-env.outputs.modcache }}
33+
1934
- run: go version
2035
- run: go test ./...
2136
- run: go test -race ./...

brotli.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ var (
9292
//
9393
// Supported compression levels are:
9494
//
95-
// * CompressBrotliNoCompression
96-
// * CompressBrotliBestSpeed
97-
// * CompressBrotliBestCompression
98-
// * CompressBrotliDefaultCompression
95+
// - CompressBrotliNoCompression
96+
// - CompressBrotliBestSpeed
97+
// - CompressBrotliBestCompression
98+
// - CompressBrotliDefaultCompression
9999
func AppendBrotliBytesLevel(dst, src []byte, level int) []byte {
100100
w := &byteSliceWriter{dst}
101101
WriteBrotliLevel(w, src, level) //nolint:errcheck
@@ -107,10 +107,10 @@ func AppendBrotliBytesLevel(dst, src []byte, level int) []byte {
107107
//
108108
// Supported compression levels are:
109109
//
110-
// * CompressBrotliNoCompression
111-
// * CompressBrotliBestSpeed
112-
// * CompressBrotliBestCompression
113-
// * CompressBrotliDefaultCompression
110+
// - CompressBrotliNoCompression
111+
// - CompressBrotliBestSpeed
112+
// - CompressBrotliBestCompression
113+
// - CompressBrotliDefaultCompression
114114
func WriteBrotliLevel(w io.Writer, p []byte, level int) (int, error) {
115115
switch w.(type) {
116116
case *byteSliceWriter,

client.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1467,7 +1467,7 @@ func (e *timeoutError) Error() string {
14671467
// Only implement the Timeout() function of the net.Error interface.
14681468
// This allows for checks like:
14691469
//
1470-
// if x, ok := err.(interface{ Timeout() bool }); ok && x.Timeout() {
1470+
// if x, ok := err.(interface{ Timeout() bool }); ok && x.Timeout() {
14711471
func (e *timeoutError) Timeout() bool {
14721472
return true
14731473
}

compress.go

+20-20
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,11 @@ var (
127127
//
128128
// Supported compression levels are:
129129
//
130-
// * CompressNoCompression
131-
// * CompressBestSpeed
132-
// * CompressBestCompression
133-
// * CompressDefaultCompression
134-
// * CompressHuffmanOnly
130+
// - CompressNoCompression
131+
// - CompressBestSpeed
132+
// - CompressBestCompression
133+
// - CompressDefaultCompression
134+
// - CompressHuffmanOnly
135135
func AppendGzipBytesLevel(dst, src []byte, level int) []byte {
136136
w := &byteSliceWriter{dst}
137137
WriteGzipLevel(w, src, level) //nolint:errcheck
@@ -143,11 +143,11 @@ func AppendGzipBytesLevel(dst, src []byte, level int) []byte {
143143
//
144144
// Supported compression levels are:
145145
//
146-
// * CompressNoCompression
147-
// * CompressBestSpeed
148-
// * CompressBestCompression
149-
// * CompressDefaultCompression
150-
// * CompressHuffmanOnly
146+
// - CompressNoCompression
147+
// - CompressBestSpeed
148+
// - CompressBestCompression
149+
// - CompressDefaultCompression
150+
// - CompressHuffmanOnly
151151
func WriteGzipLevel(w io.Writer, p []byte, level int) (int, error) {
152152
switch w.(type) {
153153
case *byteSliceWriter,
@@ -223,11 +223,11 @@ func AppendGunzipBytes(dst, src []byte) ([]byte, error) {
223223
//
224224
// Supported compression levels are:
225225
//
226-
// * CompressNoCompression
227-
// * CompressBestSpeed
228-
// * CompressBestCompression
229-
// * CompressDefaultCompression
230-
// * CompressHuffmanOnly
226+
// - CompressNoCompression
227+
// - CompressBestSpeed
228+
// - CompressBestCompression
229+
// - CompressDefaultCompression
230+
// - CompressHuffmanOnly
231231
func AppendDeflateBytesLevel(dst, src []byte, level int) []byte {
232232
w := &byteSliceWriter{dst}
233233
WriteDeflateLevel(w, src, level) //nolint:errcheck
@@ -239,11 +239,11 @@ func AppendDeflateBytesLevel(dst, src []byte, level int) []byte {
239239
//
240240
// Supported compression levels are:
241241
//
242-
// * CompressNoCompression
243-
// * CompressBestSpeed
244-
// * CompressBestCompression
245-
// * CompressDefaultCompression
246-
// * CompressHuffmanOnly
242+
// - CompressNoCompression
243+
// - CompressBestSpeed
244+
// - CompressBestCompression
245+
// - CompressDefaultCompression
246+
// - CompressHuffmanOnly
247247
func WriteDeflateLevel(w io.Writer, p []byte, level int) (int, error) {
248248
switch w.(type) {
249249
case *byteSliceWriter,

doc.go

+48-30
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,53 @@ Package fasthttp provides fast HTTP server and client API.
33
44
Fasthttp provides the following features:
55
6-
* Optimized for speed. Easily handles more than 100K qps and more than 1M
7-
concurrent keep-alive connections on modern hardware.
8-
* Optimized for low memory usage.
9-
* Easy 'Connection: Upgrade' support via RequestCtx.Hijack.
10-
* Server provides the following anti-DoS limits:
11-
12-
* The number of concurrent connections.
13-
* The number of concurrent connections per client IP.
14-
* The number of requests per connection.
15-
* Request read timeout.
16-
* Response write timeout.
17-
* Maximum request header size.
18-
* Maximum request body size.
19-
* Maximum request execution time.
20-
* Maximum keep-alive connection lifetime.
21-
* Early filtering out non-GET requests.
22-
23-
* A lot of additional useful info is exposed to request handler:
24-
25-
* Server and client address.
26-
* Per-request logger.
27-
* Unique request id.
28-
* Request start time.
29-
* Connection start time.
30-
* Request sequence number for the current connection.
31-
32-
* Client supports automatic retry on idempotent requests' failure.
33-
* Fasthttp API is designed with the ability to extend existing client
34-
and server implementations or to write custom client and server
35-
implementations from scratch.
6+
1. Optimized for speed. Easily handles more than 100K qps and more than 1M
7+
concurrent keep-alive connections on modern hardware.
8+
9+
2. Optimized for low memory usage.
10+
11+
3. Easy 'Connection: Upgrade' support via RequestCtx.Hijack.
12+
13+
4. Server provides the following anti-DoS limits:
14+
15+
- The number of concurrent connections.
16+
17+
- The number of concurrent connections per client IP.
18+
19+
- The number of requests per connection.
20+
21+
- Request read timeout.
22+
23+
- Response write timeout.
24+
25+
- Maximum request header size.
26+
27+
- Maximum request body size.
28+
29+
- Maximum request execution time.
30+
31+
- Maximum keep-alive connection lifetime.
32+
33+
- Early filtering out non-GET requests.
34+
35+
5. A lot of additional useful info is exposed to request handler:
36+
37+
- Server and client address.
38+
39+
- Per-request logger.
40+
41+
- Unique request id.
42+
43+
- Request start time.
44+
45+
- Connection start time.
46+
47+
- Request sequence number for the current connection.
48+
49+
6. Client supports automatic retry on idempotent requests' failure.
50+
51+
7. Fasthttp API is designed with the ability to extend existing client
52+
and server implementations or to write custom client and server
53+
implementations from scratch.
3654
*/
3755
package fasthttp

fasthttpadaptor/adaptor.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ import (
1515
// it has the following drawbacks comparing to using manually written fasthttp
1616
// request handler:
1717
//
18-
// * A lot of useful functionality provided by fasthttp is missing
19-
// from net/http handler.
20-
// * net/http -> fasthttp handler conversion has some overhead,
21-
// so the returned handler will be always slower than manually written
22-
// fasthttp handler.
18+
// - A lot of useful functionality provided by fasthttp is missing
19+
// from net/http handler.
20+
// - net/http -> fasthttp handler conversion has some overhead,
21+
// so the returned handler will be always slower than manually written
22+
// fasthttp handler.
2323
//
2424
// So it is advisable using this function only for quick net/http -> fasthttp
2525
// switching. Then manually convert net/http handlers to fasthttp handlers
@@ -35,11 +35,11 @@ func NewFastHTTPHandlerFunc(h http.HandlerFunc) fasthttp.RequestHandler {
3535
// it has the following drawbacks comparing to using manually written fasthttp
3636
// request handler:
3737
//
38-
// * A lot of useful functionality provided by fasthttp is missing
39-
// from net/http handler.
40-
// * net/http -> fasthttp handler conversion has some overhead,
41-
// so the returned handler will be always slower than manually written
42-
// fasthttp handler.
38+
// - A lot of useful functionality provided by fasthttp is missing
39+
// from net/http handler.
40+
// - net/http -> fasthttp handler conversion has some overhead,
41+
// so the returned handler will be always slower than manually written
42+
// fasthttp handler.
4343
//
4444
// So it is advisable using this function only for quick net/http -> fasthttp
4545
// switching. Then manually convert net/http handlers to fasthttp handlers

fasthttpproxy/http.go

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
// the provided HTTP proxy.
1616
//
1717
// Example usage:
18+
//
1819
// c := &fasthttp.Client{
1920
// Dial: fasthttpproxy.FasthttpHTTPDialer("username:password@localhost:9050"),
2021
// }
@@ -26,6 +27,7 @@ func FasthttpHTTPDialer(proxy string) fasthttp.DialFunc {
2627
// the provided HTTP proxy using the given timeout.
2728
//
2829
// Example usage:
30+
//
2931
// c := &fasthttp.Client{
3032
// Dial: fasthttpproxy.FasthttpHTTPDialerTimeout("username:password@localhost:9050", time.Second * 2),
3133
// }

fasthttpproxy/proxy_env.go

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const (
2424
// the the env(HTTP_PROXY, HTTPS_PROXY and NO_PROXY) configured HTTP proxy.
2525
//
2626
// Example usage:
27+
//
2728
// c := &fasthttp.Client{
2829
// Dial: FasthttpProxyHTTPDialer(),
2930
// }
@@ -35,6 +36,7 @@ func FasthttpProxyHTTPDialer() fasthttp.DialFunc {
3536
// the env(HTTP_PROXY, HTTPS_PROXY and NO_PROXY) configured HTTP proxy using the given timeout.
3637
//
3738
// Example usage:
39+
//
3840
// c := &fasthttp.Client{
3941
// Dial: FasthttpProxyHTTPDialerTimeout(time.Second * 2),
4042
// }

fasthttpproxy/socks5.go

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
// the provided SOCKS5 proxy.
1313
//
1414
// Example usage:
15+
//
1516
// c := &fasthttp.Client{
1617
// Dial: fasthttpproxy.FasthttpSocksDialer("socks5://localhost:9050"),
1718
// }

fasthttputil/pipeconns.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ func NewPipeConns() *PipeConns {
3535
// PipeConns has the following additional features comparing to connections
3636
// returned from net.Pipe():
3737
//
38-
// * It is faster.
39-
// * It buffers Write calls, so there is no need to have concurrent goroutine
38+
// - It is faster.
39+
// - It buffers Write calls, so there is no need to have concurrent goroutine
4040
// calling Read in order to unblock each Write call.
41-
// * It supports read and write deadlines.
41+
// - It supports read and write deadlines.
4242
//
4343
// PipeConns is NOT safe for concurrent use by multiple goroutines!
4444
type PipeConns struct {
@@ -209,7 +209,7 @@ func (e *timeoutError) Error() string {
209209
// Only implement the Timeout() function of the net.Error interface.
210210
// This allows for checks like:
211211
//
212-
// if x, ok := err.(interface{ Timeout() bool }); ok && x.Timeout() {
212+
// if x, ok := err.(interface{ Timeout() bool }); ok && x.Timeout() {
213213
func (e *timeoutError) Timeout() bool {
214214
return true
215215
}

0 commit comments

Comments
 (0)