diff --git a/mux.go b/mux.go index f126a60..30f1672 100644 --- a/mux.go +++ b/mux.go @@ -363,9 +363,9 @@ func (r *Router) Walk(walkFn WalkFunc) error { return r.walk(walkFn, []*Route{}) } -// SkipRouter is used as a return value from WalkFuncs to indicate that the +// ErrSkipRouter is used as a return value from WalkFuncs to indicate that the // router that walk is about to descend down to should be skipped. -var SkipRouter = errors.New("skip this router") +var ErrSkipRouter = errors.New("skip this router") // WalkFunc is the type of the function called for each route visited by Walk. // At every invocation, it is given the current route, and the current router, @@ -375,7 +375,7 @@ type WalkFunc func(route *Route, router *Router, ancestors []*Route) error func (r *Router) walk(walkFn WalkFunc, ancestors []*Route) error { for _, t := range r.routes { err := walkFn(t, r, ancestors) - if err == SkipRouter { + if err == ErrSkipRouter { continue } if err != nil { diff --git a/mux_test.go b/mux_test.go index 2d8d2b3..4c88a2f 100644 --- a/mux_test.go +++ b/mux_test.go @@ -1600,7 +1600,7 @@ func TestWalkSingleDepth(t *testing.T) { err := r0.Walk(func(route *Route, router *Router, ancestors []*Route) error { matcher := route.matchers[0].(*routeRegexp) if matcher.template == "/d" { - return SkipRouter + return ErrSkipRouter } if len(ancestors) != depths[i] { t.Errorf(`Expected depth of %d at i = %d; got "%d"`, depths[i], i, len(ancestors)) diff --git a/regexp_test.go b/regexp_test.go index 0d80e6a..d7518f3 100644 --- a/regexp_test.go +++ b/regexp_test.go @@ -54,7 +54,7 @@ func Benchmark_findQueryKey(b *testing.B) { b.ReportAllocs() b.ResetTimer() for i := 0; i < b.N; i++ { - for key, _ := range all { + for key := range all { _, _ = findFirstQueryKey(query, key) } } @@ -79,7 +79,7 @@ func Benchmark_findQueryKeyGoLib(b *testing.B) { b.ReportAllocs() b.ResetTimer() for i := 0; i < b.N; i++ { - for key, _ := range all { + for key := range all { v := u.Query()[key] if len(v) > 0 { _ = v[0]