Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

go vet false positive with input from list of file *.go #7

Closed
meomap opened this issue Nov 23, 2016 · 4 comments
Closed

go vet false positive with input from list of file *.go #7

meomap opened this issue Nov 23, 2016 · 4 comments
Assignees

Comments

@meomap
Copy link

meomap commented Nov 23, 2016

I have default linter on top of 3 repository and it output false positive go vet error.

~/testlinter/src/meomap] 12s $ go test --run TestLint
--- FAIL: TestLint (2.33s)
        lint_test.go:17: lint failures: govet.Check: /Users/meomap/testlinter/src/meomap/b/main.go:9: declaration of "foo" shadows declaration at /Users/meomap/testlinter/src/meomap/a/main.go:3
FAIL
exit status 1
FAIL    meomap  2.342s

It seems the linter run this go vet command

$ go tool vet --shadow a/main.go b/main.go c/main.go 

and I opened an issue at golang project here but it closed

golang/go#18018

Is there any reason why the vet command have to run with list of *.go file instead of greedy argument . ?

@sridharv
Copy link
Contributor

Thanks for the bug report!

This is a bug in how govet.Check is implemented. All go files from all packages are pulled and passed to govet when the files should be passed on a per-package basis. The reasoning being given at golang/go/#18018 is sound. I'll update lint to behave correctly.

@sridharv
Copy link
Contributor

As an added note, the reason the directory is not used is because go vet recurses into all subdirectories as well and if a single package has been specified this might not be the expected behaviour.

@sridharv sridharv self-assigned this Nov 23, 2016
sridharv added a commit that referenced this issue Nov 23, 2016
As reported in issue #7, the current usage of govet is buggy.
All files in all packages are passed together as a large glob.
To avoid this issue files are now passed in per-package fileset.
sridharv added a commit that referenced this issue Nov 23, 2016
As reported in issue #7, the current usage of govet is buggy.
All files in all packages are passed together as a large glob.
To avoid this issue files are now passed in per-package fileset.
@sridharv
Copy link
Contributor

I've pushed a fix and I'm closing this issue. Please pull the latest and see if it fixes the problem for you. If not please re-open this issue.

@meomap
Copy link
Author

meomap commented Nov 23, 2016

@sridharv thanks, I pull the lastest version and it works as expected !

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

No branches or pull requests

2 participants