mirror of
https://github.com/valyala/fasthttp.git
synced 2026-06-14 15:56:44 +03:00
chore: Set max line length to 130 characters (#1676)
This commit is contained in:
+9
-1
@@ -27,7 +27,6 @@ linters:
|
||||
- gosec
|
||||
- inamedparam
|
||||
- ireturn
|
||||
- lll
|
||||
- maintidx
|
||||
- nakedret
|
||||
- nestif
|
||||
@@ -70,3 +69,12 @@ linters-settings:
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md
|
||||
rules:
|
||||
- name: use-any
|
||||
lll:
|
||||
line-length: 130
|
||||
|
||||
issues:
|
||||
exclude-rules:
|
||||
# Exclude some linters from running on tests files.
|
||||
- path: _test\.go
|
||||
linters:
|
||||
- lll
|
||||
|
||||
@@ -1047,7 +1047,8 @@ var (
|
||||
ErrTooManyRedirects = errors.New("too many redirects detected when doing the request")
|
||||
|
||||
// HostClients are only able to follow redirects to the same protocol.
|
||||
ErrHostClientRedirectToDifferentScheme = errors.New("HostClient can't follow redirects to a different protocol, please use Client instead")
|
||||
ErrHostClientRedirectToDifferentScheme = errors.New("HostClient can't follow redirects to a different protocol," +
|
||||
" please use Client instead")
|
||||
)
|
||||
|
||||
const defaultMaxRedirectsCount = 16
|
||||
@@ -1069,7 +1070,9 @@ func doRequestFollowRedirectsBuffer(req *Request, dst []byte, url string, c clie
|
||||
return statusCode, body, err
|
||||
}
|
||||
|
||||
func doRequestFollowRedirects(req *Request, resp *Response, url string, maxRedirectsCount int, c clientDoer) (statusCode int, body []byte, err error) {
|
||||
func doRequestFollowRedirects(
|
||||
req *Request, resp *Response, url string, maxRedirectsCount int, c clientDoer,
|
||||
) (statusCode int, body []byte, err error) {
|
||||
redirectsCount := 0
|
||||
|
||||
for {
|
||||
@@ -1939,7 +1942,10 @@ func tlsClientHandshake(rawConn net.Conn, tlsConfig *tls.Config, deadline time.T
|
||||
return conn, nil
|
||||
}
|
||||
|
||||
func dialAddr(addr string, dial DialFunc, dialWithTimeout DialFuncWithTimeout, dialDualStack, isTLS bool, tlsConfig *tls.Config, dialTimeout, writeTimeout time.Duration) (net.Conn, error) {
|
||||
func dialAddr(
|
||||
addr string, dial DialFunc, dialWithTimeout DialFuncWithTimeout, dialDualStack, isTLS bool,
|
||||
tlsConfig *tls.Config, dialTimeout, writeTimeout time.Duration,
|
||||
) (net.Conn, error) {
|
||||
deadline := time.Now().Add(writeTimeout)
|
||||
conn, err := callDialFunc(addr, dial, dialWithTimeout, dialDualStack, isTLS, dialTimeout)
|
||||
if err != nil {
|
||||
@@ -1962,7 +1968,9 @@ func dialAddr(addr string, dial DialFunc, dialWithTimeout DialFuncWithTimeout, d
|
||||
return conn, nil
|
||||
}
|
||||
|
||||
func callDialFunc(addr string, dial DialFunc, dialWithTimeout DialFuncWithTimeout, dialDualStack, isTLS bool, timeout time.Duration) (net.Conn, error) {
|
||||
func callDialFunc(
|
||||
addr string, dial DialFunc, dialWithTimeout DialFuncWithTimeout, dialDualStack, isTLS bool, timeout time.Duration,
|
||||
) (net.Conn, error) {
|
||||
if dialWithTimeout != nil {
|
||||
return dialWithTimeout(addr, timeout)
|
||||
}
|
||||
|
||||
@@ -961,7 +961,9 @@ func (cm *inMemoryCacheManager) cleanCache(pendingFiles []*fsFile) []*fsFile {
|
||||
return pendingFiles
|
||||
}
|
||||
|
||||
func cleanCacheNolock(cache map[string]*fsFile, pendingFiles, filesToRelease []*fsFile, cacheDuration time.Duration) ([]*fsFile, []*fsFile) {
|
||||
func cleanCacheNolock(
|
||||
cache map[string]*fsFile, pendingFiles, filesToRelease []*fsFile, cacheDuration time.Duration,
|
||||
) ([]*fsFile, []*fsFile) {
|
||||
t := time.Now()
|
||||
for k, ff := range cache {
|
||||
if t.Sub(ff.t) > cacheDuration {
|
||||
@@ -1381,7 +1383,9 @@ func (h *fsHandler) compressAndOpenFSFile(filePath string, fileEncoding string)
|
||||
return ff, err
|
||||
}
|
||||
|
||||
func (h *fsHandler) compressFileNolock(f fs.File, fileInfo fs.FileInfo, filePath, compressedFilePath string, fileEncoding string) (*fsFile, error) {
|
||||
func (h *fsHandler) compressFileNolock(
|
||||
f fs.File, fileInfo fs.FileInfo, filePath, compressedFilePath, fileEncoding string,
|
||||
) (*fsFile, error) {
|
||||
// Attempt to open compressed file created by another concurrent
|
||||
// goroutine.
|
||||
// It is safe opening such a file, since the file creation
|
||||
|
||||
@@ -879,7 +879,8 @@ var zeroTCPAddr = &net.TCPAddr{
|
||||
//
|
||||
// The returned value may be useful for logging.
|
||||
func (ctx *RequestCtx) String() string {
|
||||
return fmt.Sprintf("#%016X - %s<->%s - %s %s", ctx.ID(), ctx.LocalAddr(), ctx.RemoteAddr(), ctx.Request.Header.Method(), ctx.URI().FullURI())
|
||||
return fmt.Sprintf("#%016X - %s<->%s - %s %s", ctx.ID(), ctx.LocalAddr(), ctx.RemoteAddr(),
|
||||
ctx.Request.Header.Method(), ctx.URI().FullURI())
|
||||
}
|
||||
|
||||
// ID returns unique ID of the request.
|
||||
@@ -1140,7 +1141,8 @@ var (
|
||||
return nil
|
||||
}
|
||||
|
||||
// NetHttpFormValueFunc gives consistent behavior with net/http. POST and PUT body parameters take precedence over URL query string values.
|
||||
// NetHttpFormValueFunc gives consistent behavior with net/http.
|
||||
// POST and PUT body parameters take precedence over URL query string values.
|
||||
NetHttpFormValueFunc = func(ctx *RequestCtx, key string) []byte {
|
||||
v := ctx.PostArgs().Peek(key)
|
||||
if len(v) > 0 {
|
||||
@@ -1849,7 +1851,8 @@ func (s *Server) Serve(ln net.Listener) error {
|
||||
}
|
||||
|
||||
// Shutdown gracefully shuts down the server without interrupting any active connections.
|
||||
// Shutdown works by first closing all open listeners and then waiting indefinitely for all connections to return to idle and then shut down.
|
||||
// Shutdown works by first closing all open listeners and then waiting indefinitely for all connections
|
||||
// to return to idle and then shut down.
|
||||
//
|
||||
// When Shutdown is called, Serve, ListenAndServe, and ListenAndServeTLS immediately return nil.
|
||||
// Make sure the program doesn't exit and waits instead for Shutdown to return.
|
||||
@@ -1860,12 +1863,14 @@ func (s *Server) Shutdown() error {
|
||||
}
|
||||
|
||||
// ShutdownWithContext gracefully shuts down the server without interrupting any active connections.
|
||||
// ShutdownWithContext works by first closing all open listeners and then waiting for all connections to return to idle or context timeout and then shut down.
|
||||
// ShutdownWithContext works by first closing all open listeners and then waiting for all connections to return to idle
|
||||
// or context timeout and then shut down.
|
||||
//
|
||||
// When ShutdownWithContext is called, Serve, ListenAndServe, and ListenAndServeTLS immediately return nil.
|
||||
// Make sure the program doesn't exit and waits instead for Shutdown to return.
|
||||
//
|
||||
// ShutdownWithContext does not close keepalive connections so it's recommended to set ReadTimeout and IdleTimeout to something else than 0.
|
||||
// ShutdownWithContext does not close keepalive connections so it's recommended to set ReadTimeout and IdleTimeout
|
||||
// to something else than 0.
|
||||
func (s *Server) ShutdownWithContext(ctx context.Context) (err error) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
@@ -2874,7 +2879,8 @@ func (s *Server) trackConn(c net.Conn, state ConnState) {
|
||||
s.idleConns = make(map[net.Conn]time.Time)
|
||||
}
|
||||
// Count the connection as Idle after 5 seconds.
|
||||
// Same as net/http.Server: https://github.com/golang/go/blob/85d7bab91d9a3ed1f76842e4328973ea75efef54/src/net/http/server.go#L2834-L2836
|
||||
// Same as net/http.Server:
|
||||
// https://github.com/golang/go/blob/85d7bab91d9a3ed1f76842e4328973ea75efef54/src/net/http/server.go#L2834-L2836
|
||||
s.idleConns[c] = time.Now().Add(time.Second * 5)
|
||||
|
||||
default:
|
||||
|
||||
+3
-1
@@ -306,7 +306,9 @@ func (d *TCPDialer) dial(addr string, dualStack bool, timeout time.Duration) (ne
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (d *TCPDialer) tryDial(network string, addr *net.TCPAddr, deadline time.Time, concurrencyCh chan struct{}) (net.Conn, error) {
|
||||
func (d *TCPDialer) tryDial(
|
||||
network string, addr *net.TCPAddr, deadline time.Time, concurrencyCh chan struct{},
|
||||
) (net.Conn, error) {
|
||||
timeout := time.Until(deadline)
|
||||
if timeout <= 0 {
|
||||
return nil, ErrDialTimeout
|
||||
|
||||
Reference in New Issue
Block a user