Skip to content

Commit faba17a

Browse files
doniacldchavacava
andauthored
Fix package check in error-strings rule (#610) (#611)
Co-authored-by: SalvadorC <[email protected]>
1 parent 0fada9d commit faba17a

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

rule/error-strings.go

+3
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ func (w lintErrorStrings) match(expr *ast.CallExpr) bool {
105105
}
106106
// retrieve the package
107107
id, ok := sel.X.(*ast.Ident)
108+
if !ok {
109+
return false
110+
}
108111
functions, ok := w.errorFunctions[id.Name]
109112
if !ok {
110113
return false

testdata/golint/error-strings.go

+4
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,9 @@ func g(x int) error {
1616
err = fmt.Errorf("Newlines are really fun\n") // MATCH /error strings should not be capitalized or end with punctuation or a newline/
1717
err = errors.New(`too much stuff.`) // MATCH /error strings should not be capitalized or end with punctuation or a newline/
1818
err = errors.New("This %d is too low", x) // MATCH /error strings should not be capitalized or end with punctuation or a newline/
19+
20+
// Non-regression test for issue #610
21+
d.stack.Push(from)
22+
1923
return err
2024
}

0 commit comments

Comments
 (0)