Browse Source

fix golint warnings

pull/647/head
Mariano Sosto 4 years ago
parent
commit
7dc66a2eb4
  1. 6
      mux.go
  2. 2
      mux_test.go
  3. 4
      regexp_test.go

6
mux.go

@ -363,9 +363,9 @@ func (r *Router) Walk(walkFn WalkFunc) error {
return r.walk(walkFn, []*Route{}) 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. // 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. // 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, // 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 { func (r *Router) walk(walkFn WalkFunc, ancestors []*Route) error {
for _, t := range r.routes { for _, t := range r.routes {
err := walkFn(t, r, ancestors) err := walkFn(t, r, ancestors)
if err == SkipRouter { if err == ErrSkipRouter {
continue continue
} }
if err != nil { if err != nil {

2
mux_test.go

@ -1600,7 +1600,7 @@ func TestWalkSingleDepth(t *testing.T) {
err := r0.Walk(func(route *Route, router *Router, ancestors []*Route) error { err := r0.Walk(func(route *Route, router *Router, ancestors []*Route) error {
matcher := route.matchers[0].(*routeRegexp) matcher := route.matchers[0].(*routeRegexp)
if matcher.template == "/d" { if matcher.template == "/d" {
return SkipRouter return ErrSkipRouter
} }
if len(ancestors) != depths[i] { if len(ancestors) != depths[i] {
t.Errorf(`Expected depth of %d at i = %d; got "%d"`, depths[i], i, len(ancestors)) t.Errorf(`Expected depth of %d at i = %d; got "%d"`, depths[i], i, len(ancestors))

4
regexp_test.go

@ -54,7 +54,7 @@ func Benchmark_findQueryKey(b *testing.B) {
b.ReportAllocs() b.ReportAllocs()
b.ResetTimer() b.ResetTimer()
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
for key, _ := range all { for key := range all {
_, _ = findFirstQueryKey(query, key) _, _ = findFirstQueryKey(query, key)
} }
} }
@ -79,7 +79,7 @@ func Benchmark_findQueryKeyGoLib(b *testing.B) {
b.ReportAllocs() b.ReportAllocs()
b.ResetTimer() b.ResetTimer()
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
for key, _ := range all { for key := range all {
v := u.Query()[key] v := u.Query()[key]
if len(v) > 0 { if len(v) > 0 {
_ = v[0] _ = v[0]

Loading…
Cancel
Save