@@ -202,7 +202,8 @@ type testRoute struct {
202
202
func testRoutes (t * testing.T , routes []testRoute ) {
203
203
tree := & node {}
204
204
205
- for _ , route := range routes {
205
+ for i := range routes {
206
+ route := routes [i ]
206
207
recv := catchPanic (func () {
207
208
tree .addRoute (route .path , nil )
208
209
})
@@ -266,7 +267,8 @@ func TestTreeDupliatePath(t *testing.T) {
266
267
"/search/:query" ,
267
268
"/user_:name" ,
268
269
}
269
- for _ , route := range routes {
270
+ for i := range routes {
271
+ route := routes [i ]
270
272
recv := catchPanic (func () {
271
273
tree .addRoute (route , fakeHandler (route ))
272
274
})
@@ -303,7 +305,8 @@ func TestEmptyWildcardName(t *testing.T) {
303
305
"/cmd/:/" ,
304
306
"/src/*" ,
305
307
}
306
- for _ , route := range routes {
308
+ for i := range routes {
309
+ route := routes [i ]
307
310
recv := catchPanic (func () {
308
311
tree .addRoute (route , nil )
309
312
})
@@ -347,7 +350,8 @@ func TestTreeDoubleWildcard(t *testing.T) {
347
350
"/:foo*bar" ,
348
351
}
349
352
350
- for _ , route := range routes {
353
+ for i := range routes {
354
+ route := routes [i ]
351
355
tree := & node {}
352
356
recv := catchPanic (func () {
353
357
tree .addRoute (route , nil )
@@ -399,7 +403,8 @@ func TestTreeTrailingSlashRedirect(t *testing.T) {
399
403
"/no/b" ,
400
404
"/api/hello/:name" ,
401
405
}
402
- for _ , route := range routes {
406
+ for i := range routes {
407
+ route := routes [i ]
403
408
recv := catchPanic (func () {
404
409
tree .addRoute (route , fakeHandler (route ))
405
410
})
@@ -513,7 +518,8 @@ func TestTreeFindCaseInsensitivePath(t *testing.T) {
513
518
longPath ,
514
519
}
515
520
516
- for _ , route := range routes {
521
+ for i := range routes {
522
+ route := routes [i ]
517
523
recv := catchPanic (func () {
518
524
tree .addRoute (route , fakeHandler (route ))
519
525
})
@@ -524,7 +530,8 @@ func TestTreeFindCaseInsensitivePath(t *testing.T) {
524
530
525
531
// Check out == in for all registered routes
526
532
// With fixTrailingSlash = true
527
- for _ , route := range routes {
533
+ for i := range routes {
534
+ route := routes [i ]
528
535
out , found := tree .findCaseInsensitivePath (route , true )
529
536
if ! found {
530
537
t .Errorf ("Route '%s' not found!" , route )
@@ -533,7 +540,8 @@ func TestTreeFindCaseInsensitivePath(t *testing.T) {
533
540
}
534
541
}
535
542
// With fixTrailingSlash = false
536
- for _ , route := range routes {
543
+ for i := range routes {
544
+ route := routes [i ]
537
545
out , found := tree .findCaseInsensitivePath (route , false )
538
546
if ! found {
539
547
t .Errorf ("Route '%s' not found!" , route )
@@ -672,7 +680,9 @@ func TestTreeWildcardConflictEx(t *testing.T) {
672
680
{"/conooo/xxx" , "ooo" , `/con:tact` , `:tact` },
673
681
}
674
682
675
- for _ , conflict := range conflicts {
683
+ for i := range conflicts {
684
+ conflict := conflicts [i ]
685
+
676
686
// I have to re-create a 'tree', because the 'tree' will be
677
687
// in an inconsistent state when the loop recovers from the
678
688
// panic which threw by 'addRoute' function.
@@ -683,7 +693,8 @@ func TestTreeWildcardConflictEx(t *testing.T) {
683
693
"/who/foo/hello" ,
684
694
}
685
695
686
- for _ , route := range routes {
696
+ for i := range routes {
697
+ route := routes [i ]
687
698
tree .addRoute (route , fakeHandler (route ))
688
699
}
689
700
0 commit comments