From 12949de784e688451205333ebaf87ec0ca16927d Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Tue, 5 Dec 2023 20:49:41 +0200 Subject: chore: Set max line length to 130 characters (#1676) --- .golangci.yml | 10 +++++++++- client.go | 16 ++++++++++++---- fs.go | 8 ++++++-- server.go | 18 ++++++++++++------ tcpdialer.go | 4 +++- 5 files changed, 42 insertions(+), 14 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 40c1a1e..bfc873b 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -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 diff --git a/client.go b/client.go index 0bfc272..f12fea6 100644 --- a/client.go +++ b/client.go @@ -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) } diff --git a/fs.go b/fs.go index c231d80..cd27b0b 100644 --- a/fs.go +++ b/fs.go @@ -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 diff --git a/server.go b/server.go index eaafe1c..ae63571 100644 --- a/server.go +++ b/server.go @@ -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: diff --git a/tcpdialer.go b/tcpdialer.go index 77bb569..7edd79f 100644 --- a/tcpdialer.go +++ b/tcpdialer.go @@ -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 -- cgit v1.2.3