Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Set max line length to 130 characters #1676

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ linters:
- gosec
- inamedparam
- ireturn
- lll
- maintidx
- nakedret
- nestif
Expand Down Expand Up @@ -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
16 changes: 12 additions & 4 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -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)
}
Expand Down
8 changes: 6 additions & 2 deletions fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
18 changes: 12 additions & 6 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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.
Expand All @@ -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()
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion tcpdialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading