Skip to content

Commit 18bceed

Browse files
Update lint and fix new lint errors
1 parent e7d310f commit 18bceed

File tree

10 files changed

+150
-192
lines changed

10 files changed

+150
-192
lines changed

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ jobs:
2525
- name: Run golangci-lint
2626
uses: golangci/golangci-lint-action@v8
2727
with:
28-
version: v2.4.0
28+
version: v2.5.0
2929
args: --verbose

brotli.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ const (
1717
CompressBrotliBestSpeed = brotli.BestSpeed
1818
CompressBrotliBestCompression = brotli.BestCompression
1919

20-
// Choose a default brotli compression level comparable to
21-
// CompressDefaultCompression (gzip 6)
20+
// CompressBrotliDefaultCompression chooses a default brotli compression level comparable to
21+
// CompressDefaultCompression (gzip 6).
2222
// See: https://github.com/valyala/fasthttp/issues/798#issuecomment-626293806
2323
CompressBrotliDefaultCompression = 4
2424
)

client.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ type clientConn struct {
924924
lastUseTime time.Time
925925
}
926926

927-
// CreatedTime returns net.Conn the client.
927+
// Conn returns the underlying net.Conn associated with the client connection.
928928
func (cc *clientConn) Conn() net.Conn {
929929
return cc.c
930930
}
@@ -1115,7 +1115,7 @@ var (
11151115
// exceed the max count.
11161116
ErrTooManyRedirects = errors.New("too many redirects detected when doing the request")
11171117

1118-
// HostClients are only able to follow redirects to the same protocol.
1118+
// ErrHostClientRedirectToDifferentScheme is returned when a HostClient follows a redirect to a different protocol.
11191119
ErrHostClientRedirectToDifferentScheme = errors.New("HostClient can't follow redirects to a different protocol," +
11201120
" please use Client instead")
11211121
)
@@ -1522,7 +1522,7 @@ func (e *timeoutError) Error() string {
15221522
return "timeout"
15231523
}
15241524

1525-
// Only implement the Timeout() function of the net.Error interface.
1525+
// Timeout implements the Timeout behavior of the net.Error interface.
15261526
// This allows for checks like:
15271527
//
15281528
// if x, ok := err.(interface{ Timeout() bool }); ok && x.Timeout() {

fasthttpproxy/dialer.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func (d *Dialer) GetDialFunc(useEnv bool) (dialFunc fasthttp.DialFunc, err error
103103
case "socks5", "socks5h":
104104
proxyDialer, err = proxy.FromURL(proxyURL, d)
105105
if err != nil {
106-
return
106+
return nil, err
107107
}
108108
case "http":
109109
proxyAddr, auth := addrAndAuth(proxyURL)
@@ -128,7 +128,7 @@ func (d *Dialer) GetDialFunc(useEnv bool) (dialFunc fasthttp.DialFunc, err error
128128
reqURL := &url.URL{Host: addr, Scheme: scheme}
129129
proxyURL, err = proxyFunc(reqURL)
130130
if err != nil {
131-
return
131+
return nil, err
132132
}
133133
if proxyURL == nil {
134134
// dial directly
@@ -138,7 +138,7 @@ func (d *Dialer) GetDialFunc(useEnv bool) (dialFunc fasthttp.DialFunc, err error
138138
case "socks5", "socks5h":
139139
proxyDialer, err = proxy.FromURL(proxyURL, d)
140140
if err != nil {
141-
return
141+
return nil, err
142142
}
143143
case "http":
144144
proxyAddr, auth := addrAndAuth(proxyURL)
@@ -167,7 +167,7 @@ func (d *Dialer) Dial(network, addr string) (conn net.Conn, err error) {
167167
return d.TCPDialer.DialDualStack(addr)
168168
}
169169
err = errors.New("dont support the network: " + network)
170-
return
170+
return nil, err
171171
}
172172

173173
func (d *Dialer) connectTimeout() time.Duration {
@@ -193,7 +193,7 @@ func (d DialerFunc) Dial(network, addr string) (net.Conn, error) {
193193
func httpProxyDial(dialer proxy.Dialer, network, addr, proxyAddr, auth string) (conn net.Conn, err error) {
194194
conn, err = dialer.Dial(network, proxyAddr)
195195
if err != nil {
196-
return
196+
return nil, err
197197
}
198198
var connectTimeout time.Duration
199199
hp, ok := dialer.(httpProxyDialer)
@@ -218,21 +218,21 @@ func httpProxyDial(dialer proxy.Dialer, network, addr, proxyAddr, auth string) (
218218
_, err = conn.Write([]byte(req))
219219
if err != nil {
220220
_ = conn.Close()
221-
return
221+
return nil, err
222222
}
223223
res := fasthttp.AcquireResponse()
224224
defer fasthttp.ReleaseResponse(res)
225225
res.SkipBody = true
226226
if err = res.Read(bufio.NewReaderSize(conn, 1024)); err != nil {
227227
_ = conn.Close()
228-
return
228+
return nil, err
229229
}
230230
if res.Header.StatusCode() != 200 {
231231
_ = conn.Close()
232232
err = fmt.Errorf("could not connect to proxyAddr: %s status code: %d", proxyAddr, res.Header.StatusCode())
233-
return
233+
return nil, err
234234
}
235-
return
235+
return conn, err
236236
}
237237

238238
// Cache authentication information for HTTP proxies.
@@ -244,7 +244,7 @@ type proxyInfo struct {
244244
func addrAndAuth(pu *url.URL) (proxyAddr, auth string) {
245245
if pu.User == nil {
246246
proxyAddr = pu.Host + pu.Path
247-
return
247+
return proxyAddr, auth
248248
}
249249
var info *proxyInfo
250250
v, ok := authCache.Load(pu)

fasthttpproxy/dialer_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ func startProxyServer(t *testing.T, ports []string, counts []atomic.Int64) (lns
273273
fasthttp.ReleaseRequest(req)
274274
}()
275275
}
276-
return
276+
return lns
277277
}
278278

279279
func getDialer(httpProxy, httpsProxy, noProxy string) *Dialer {
@@ -290,7 +290,7 @@ func getCounts(counts []atomic.Int64) (r []int64) {
290290
for i := 0; i < len(counts); i++ {
291291
r = append(r, counts[i].Load())
292292
}
293-
return
293+
return r
294294
}
295295

296296
func countsEqual(a, b []int64) bool {

fasthttputil/pipeconns.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ func (e *timeoutError) Error() string {
229229
return "timeout"
230230
}
231231

232-
// Only implement the Timeout() function of the net.Error interface.
232+
// Timeout implements the Timeout method of the net.Error interface.
233233
// This allows for checks like:
234234
//
235235
// if x, ok := err.(interface{ Timeout() bool }); ok && x.Timeout() {

0 commit comments

Comments
 (0)