Skip to content
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
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ linters:
- importas
- ineffassign
- misspell
- modernize
- prealloc
- promlinter
- sloglint
Expand Down
2 changes: 1 addition & 1 deletion caddyconfig/caddyfile/dispenser.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ func (d *Dispenser) File() string {
// targets are left unchanged. If all the targets are filled,
// then true is returned.
func (d *Dispenser) Args(targets ...*string) bool {
for i := 0; i < len(targets); i++ {
for i := range targets {
if !d.NextArg() {
return false
}
Expand Down
2 changes: 1 addition & 1 deletion caddyconfig/caddyfile/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ func (p *parser) doSingleImport(importFile string) ([]Token, error) {
if err != nil {
return nil, p.Errf("Failed to get absolute path of file: %s: %v", importFile, err)
}
for i := 0; i < len(importedTokens); i++ {
for i := range importedTokens {
importedTokens[i].File = filename
}

Expand Down
2 changes: 1 addition & 1 deletion caddyconfig/httploader.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func doHttpCallWithRetries(ctx caddy.Context, client *http.Client, request *http
var err error
const maxAttempts = 10

for i := 0; i < maxAttempts; i++ {
for i := range maxAttempts {
resp, err = attemptHttpCall(client, request)
if err != nil && i < maxAttempts-1 {
select {
Expand Down
2 changes: 1 addition & 1 deletion listeners.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func (na NetworkAddress) JoinHostPort(offset uint) string {
func (na NetworkAddress) Expand() []NetworkAddress {
size := na.PortRangeSize()
addrs := make([]NetworkAddress, size)
for portOffset := uint(0); portOffset < size; portOffset++ {
for portOffset := range size {
addrs[portOffset] = na.At(portOffset)
}
return addrs
Expand Down
6 changes: 3 additions & 3 deletions modules/caddyhttp/headers/headers.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,11 @@ func (ops *HeaderOps) Provision(_ caddy.Context) error {

// containsPlaceholders checks if the string contains Caddy placeholder syntax {key}
func containsPlaceholders(s string) bool {
openIdx := strings.Index(s, "{")
if openIdx == -1 {
_, after, ok := strings.Cut(s, "{")
if !ok {
return false
}
closeIdx := strings.Index(s[openIdx+1:], "}")
closeIdx := strings.Index(after, "}")
if closeIdx == -1 {
return false
}
Expand Down
4 changes: 2 additions & 2 deletions modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ func (t Transport) splitPos(path string) int {
for _, split := range t.SplitPath {
splitLen := len(split)

for i := 0; i < pathLen; i++ {
for i := range pathLen {
if path[i] >= utf8.RuneSelf {
if _, end := splitSearchNonASCII.IndexString(path, split); end > -1 {
return end
Expand All @@ -456,7 +456,7 @@ func (t Transport) splitPos(path string) int {
}

match := true
for j := 0; j < splitLen; j++ {
for j := range splitLen {
c := path[i+j]

if c >= utf8.RuneSelf {
Expand Down
2 changes: 1 addition & 1 deletion modules/caddyhttp/reverseproxy/selectionpolicies.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ func (r *RoundRobinSelection) Select(pool UpstreamPool, _ *http.Request, _ http.
if n == 0 {
return nil
}
for i := uint32(0); i < n; i++ {
for range n {
robin := atomic.AddUint32(&r.robin, 1)
host := pool[robin%n]
if host.Available() {
Expand Down
2 changes: 1 addition & 1 deletion modules/caddyhttp/reverseproxy/streaming.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ func maskBytes(key [4]byte, pos int, b []byte) int {
// Mask one word at a time.
n := (len(b) / wordSize) * wordSize
for i := 0; i < n; i += wordSize {
*(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&b[0])) + uintptr(i))) ^= kw
*(*uintptr)(unsafe.Add(unsafe.Pointer(&b[0]), i)) ^= kw
}

// Mask one byte at a time for remaining bytes.
Expand Down
2 changes: 1 addition & 1 deletion modules/logging/filewriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (m *fileMode) UnmarshalJSON(b []byte) error {

// MarshalJSON satisfies json.Marshaler.
func (m *fileMode) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf("\"%04o\"", *m)), nil
return fmt.Appendf(nil, "\"%04o\"", *m), nil
}

// parseFileMode parses a file mode string,
Expand Down
Loading