@marcel91200 / caddy Mirror · read-only / commits / 72eaf258
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 11, 14:45 UTC

chore: Enable modernize linter (#7519)

Oleksandr Redko committed Feb 26, 2026 at 23:01 UTC 72eaf2583ae70c352b6496598b0c3dc19820ace3
10 files changed +13 -12
.golangci.yml
+1
@@ -32,6 +32,7 @@ linters:
32 - importas
33 - ineffassign
34 - misspell
35 + - modernize
36 - prealloc
37 - promlinter
38 - sloglint
caddyconfig/caddyfile/dispenser.go
+1 -1
@@ -270,7 +270,7 @@ func (d *Dispenser) File() string {
270 // targets are left unchanged. If all the targets are filled,
271 // then true is returned.
272 func (d *Dispenser) Args(targets ...*string) bool {
273 - for i := 0; i < len(targets); i++ {
273 + for i := range targets {
274 if !d.NextArg() {
275 return false
276 }
caddyconfig/caddyfile/parse.go
+1 -1
@@ -616,7 +616,7 @@ func (p *parser) doSingleImport(importFile string) ([]Token, error) {
616 if err != nil {
617 return nil, p.Errf("Failed to get absolute path of file: %s: %v", importFile, err)
618 }
619 - for i := 0; i < len(importedTokens); i++ {
619 + for i := range importedTokens {
620 importedTokens[i].File = filename
621 }
622
caddyconfig/httploader.go
+1 -1
@@ -151,7 +151,7 @@ func doHttpCallWithRetries(ctx caddy.Context, client *http.Client, request *http
151 var err error
152 const maxAttempts = 10
153
154 - for i := 0; i < maxAttempts; i++ {
154 + for i := range maxAttempts {
155 resp, err = attemptHttpCall(client, request)
156 if err != nil && i < maxAttempts-1 {
157 select {
listeners.go
+1 -1
@@ -229,7 +229,7 @@ func (na NetworkAddress) JoinHostPort(offset uint) string {
229 func (na NetworkAddress) Expand() []NetworkAddress {
230 size := na.PortRangeSize()
231 addrs := make([]NetworkAddress, size)
232 - for portOffset := uint(0); portOffset < size; portOffset++ {
232 + for portOffset := range size {
233 addrs[portOffset] = na.At(portOffset)
234 }
235 return addrs
modules/caddyhttp/headers/headers.go
+3 -3
@@ -161,11 +161,11 @@ func (ops *HeaderOps) Provision(_ caddy.Context) error {
161
162 // containsPlaceholders checks if the string contains Caddy placeholder syntax {key}
163 func containsPlaceholders(s string) bool {
164 - openIdx := strings.Index(s, "{")
165 - if openIdx == -1 {
164 + _, after, ok := strings.Cut(s, "{")
165 + if !ok {
166 return false
167 }
168 - closeIdx := strings.Index(s[openIdx+1:], "}")
168 + closeIdx := strings.Index(after, "}")
169 if closeIdx == -1 {
170 return false
171 }
modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go
+2 -2
@@ -442,7 +442,7 @@ func (t Transport) splitPos(path string) int {
442 for _, split := range t.SplitPath {
443 splitLen := len(split)
444
445 - for i := 0; i < pathLen; i++ {
445 + for i := range pathLen {
446 if path[i] >= utf8.RuneSelf {
447 if _, end := splitSearchNonASCII.IndexString(path, split); end > -1 {
448 return end
@@ -456,7 +456,7 @@ func (t Transport) splitPos(path string) int {
456 }
457
458 match := true
459 - for j := 0; j < splitLen; j++ {
459 + for j := range splitLen {
460 c := path[i+j]
461
462 if c >= utf8.RuneSelf {
modules/caddyhttp/reverseproxy/selectionpolicies.go
+1 -1
@@ -312,7 +312,7 @@ func (r *RoundRobinSelection) Select(pool UpstreamPool, _ *http.Request, _ http.
312 if n == 0 {
313 return nil
314 }
315 - for i := uint32(0); i < n; i++ {
315 + for range n {
316 robin := atomic.AddUint32(&r.robin, 1)
317 host := pool[robin%n]
318 if host.Available() {
modules/caddyhttp/reverseproxy/streaming.go
+1 -1
@@ -536,7 +536,7 @@ func maskBytes(key [4]byte, pos int, b []byte) int {
536 // Mask one word at a time.
537 n := (len(b) / wordSize) * wordSize
538 for i := 0; i < n; i += wordSize {
539 - *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&b[0])) + uintptr(i))) ^= kw
539 + *(*uintptr)(unsafe.Add(unsafe.Pointer(&b[0]), i)) ^= kw
540 }
541
542 // Mask one byte at a time for remaining bytes.
modules/logging/filewriter.go
+1 -1
@@ -63,7 +63,7 @@ func (m *fileMode) UnmarshalJSON(b []byte) error {
63
64 // MarshalJSON satisfies json.Marshaler.
65 func (m *fileMode) MarshalJSON() ([]byte, error) {
66 - return []byte(fmt.Sprintf("\"%04o\"", *m)), nil
66 + return fmt.Appendf(nil, "\"%04o\"", *m), nil
67 }
68
69 // parseFileMode parses a file mode string,