kisielk / errcheck

errcheck checks that you checked errors.
MIT License
2.33k stars 138 forks source link

The `-exclude` option does not seem to work for functions declared in the same package #251

Open FlorentClarret opened 3 weeks ago

FlorentClarret commented 3 weeks ago

I have this very simple example:

First file:

package first

func FirstFunc() error {
    return nil
}

func ThirdFunc() error {
    FirstFunc()
    return nil
}

Second file:

package second

import "testerrcheck/first"

func SecondFunc() error {
    first.FirstFunc()
    return nil
}

Exclude file:

testerrcheck/first.FirstFunc

When I run errcheck -exclude exclude.txt ./... I get:

first/file.go:8:11:     FirstFunc()

The exclusion is properly working for the function called in the second package, but not from within its own package, in the first package.

kisielk commented 3 weeks ago

Thanks, this does indeed seem like a bug