Skip to content

Commit 6a97fb2

Browse files
committed
run "go fix" from go-1.26
1 parent d5e4e73 commit 6a97fb2

File tree

8 files changed

+13
-17
lines changed

8 files changed

+13
-17
lines changed

pkg/camo/encoding/url.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func b64encode(data []byte) string {
4444

4545
func b64decode(str string) ([]byte, error) {
4646
padChars := (4 - (len(str) % 4)) % 4
47-
for i := 0; i < padChars; i++ {
47+
for range padChars {
4848
str = str + "="
4949
}
5050
decBytes, ok := base64.URLEncoding.DecodeString(str)

pkg/camo/helpers_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ import (
1414
"reflect"
1515
"testing"
1616

17+
"codeberg.org/dropwhile/assert"
1718
"github.com/cactus/go-camo/v2/pkg/camo/encoding"
1819
"github.com/cactus/go-camo/v2/pkg/router"
19-
"codeberg.org/dropwhile/assert"
2020
)
2121

2222
func makeReq(config Config, testURL string) (*http.Request, error) {
@@ -119,7 +119,7 @@ func (r *Tuple[A, B]) UnmarshalJSON(p []byte) error {
119119
return err
120120
}
121121

122-
if reflect.TypeOf(&r.b) == reflect.TypeFor[*B]() {
122+
if reflect.TypeFor[*B]() == reflect.TypeFor[*B]() {
123123
var s string
124124
if err := json.Unmarshal(tmp[1], &s); err != nil {
125125
return err

pkg/camo/proxy_filter_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func TestFilterListMatrixMultiples(t *testing.T) {
6767
t.Fatal(err)
6868
}
6969

70-
for i := 0; i < 3; i++ {
70+
for i := range 3 {
7171
filters = append(
7272
filters, func(x int) FilterFunc {
7373
return func(*url.URL) (bool, error) {

pkg/camo/upstream_proxy.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"fmt"
1111
"net"
1212
"net/url"
13+
"slices"
1314

1415
"golang.org/x/net/http/httpproxy"
1516
)
@@ -34,12 +35,7 @@ func (ic *innerUpstreamProxyConfig) matchesIP(ip net.IP, port string) bool {
3435
return false
3536
}
3637

37-
for i := range ic.addresses {
38-
if ip.Equal(ic.addresses[i]) {
39-
return true
40-
}
41-
}
42-
return false
38+
return slices.ContainsFunc(ic.addresses, ip.Equal)
4339
}
4440

4541
func (ic *innerUpstreamProxyConfig) matchesHost(host string, port string) bool {

pkg/htrie/glob_path_chk_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ func BenchmarkGlobPathChecker(b *testing.B) {
157157
for _, u := range testMatch {
158158
u, _ := url.Parse(u)
159159
z := u.EscapedPath()
160-
for i := 0; i < testIters; i++ {
160+
for range testIters {
161161
x = gpc.CheckPath(z)
162162
}
163163
}

pkg/htrie/glob_path_node.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func (gpn *globPathNode) addPath(s string) error {
7171
curnode := gpn
7272
prevnode := curnode
7373
mlen := len(s)
74-
for i := 0; i < mlen; i++ {
74+
for i := range mlen {
7575
part := uint32(s[i])
7676

7777
// if icase, use lowercase letters for comparisons

pkg/htrie/htrie.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func putURLMatcherSlice(s *[]*URLMatcher) {
5252

5353
func reverse(s []string) []string {
5454
c := len(s) / 2
55-
for i := 0; i < c; i++ {
55+
for i := range c {
5656
j := len(s) - i - 1
5757
s[i], s[j] = s[j], s[i]
5858
}

pkg/htrie/htrie_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ func BenchmarkHTrieMatch(b *testing.B) {
212212
b.ResetTimer()
213213

214214
for _, u := range parsed {
215-
for i := 0; i < testIters; i++ {
215+
for range testIters {
216216
x, _ = dt.CheckURL(u)
217217
}
218218
}
@@ -249,7 +249,7 @@ func BenchmarkRegexMatch(b *testing.B) {
249249
b.ResetTimer()
250250

251251
for _, u := range testUrls {
252-
for i := 0; i < testIters; i++ {
252+
for range testIters {
253253
// walk regexes in order. first match wins
254254
for _, rx := range rexes {
255255
if rx.MatchString(u) {
@@ -292,15 +292,15 @@ func BenchmarkHTrieMatchHostname(b *testing.B) {
292292

293293
b.Run("CheckHostname", func(b *testing.B) {
294294
for _, u := range parsed {
295-
for i := 0; i < testIters; i++ {
295+
for range testIters {
296296
x, _ = dt.CheckHostname(u)
297297
}
298298
}
299299
})
300300

301301
b.Run("CheckCleanHostname", func(b *testing.B) {
302302
for _, u := range parsed {
303-
for i := 0; i < testIters; i++ {
303+
for range testIters {
304304
x = dt.CheckCleanHostname(u)
305305
}
306306
}

0 commit comments

Comments
 (0)