Skip to content
This repository has been archived by the owner on May 9, 2021. It is now read-only.

Commit

Permalink
lint: add test case to cover allowed errors.New(fmt.Sprintf()) cases
Browse files Browse the repository at this point in the history
Updates #350
  • Loading branch information
leonelquinteros committed Mar 1, 2018
1 parent 70f7b1a commit 71ea537
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions testdata/errorf-custom.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Test for allowed errors.New(fmt.Sprintf()) when a custom errors package is imported.

// Package foo ...
package foo

import (
"fmt"

"github.com/pkg/errors"
)

func f(x int) error {
if x > 10 {
return errors.New(fmt.Sprintf("something %d", x)) // OK
}
if x > 5 {
return errors.New(g("blah")) // OK
}
if x > 4 {
return errors.New("something else") // OK
}
return nil
}

func g(s string) string { return "prefix: " + s }

0 comments on commit 71ea537

Please sign in to comment.