Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Example of ignoring functions outside standard library #139

Closed
alexflint opened this issue Apr 23, 2018 · 4 comments
Closed

Example of ignoring functions outside standard library #139

alexflint opened this issue Apr 23, 2018 · 4 comments

Comments

@alexflint
Copy link

I am attempting to add the function "Println" in the package github.com/kr/pretty to my errcheck ignore file. However, none of the following lines result in the error being excluded:

github.com/kr/pretty.Println
"github.com/kr/pretty".Println
(github.com/kr/pretty).Println
("github.com/kr/pretty").Println
pretty.Println

The command I'm using is (and I can successfully ignore other functions inside the standard library):

errcheck -exclude .lint/errcheck-excludes src.go

The error I see is:

src.go:37:16:	pretty.Println(r)

The function signature is:

func Println(a ...interface{}) (n int, errno error)
@kisielk
Copy link
Owner

kisielk commented Apr 23, 2018

hm, maybe it would be useful if there was a flag for also printing the function name alongside the line so that it was easier to make the excludes.

@alexflint
Copy link
Author

alexflint commented Apr 23, 2018

Ah it looks like I can get the full function name with -v and what I needed to put into my exclude file was:

github.com/alexflint/myproject/vendor/github.com/kr/pretty.Println

I understand what's going on here but it doesn't seem very easy to discover.

@tymonx
Copy link

tymonx commented May 19, 2020

I have a similar issue with that. The -v is not present and the -verbose flag is not useful. I cannot get how to properly exclude some methods.

kisielk added a commit that referenced this issue Jun 19, 2020
Fix #139: Add example of excluding a call to a vendored dependency
@lishunan246
Copy link

What if I am using go modules rather than vendored dependencies?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants