-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
structcheck returns false positives, for variables defined in different file, in the same package #537
Comments
same with me |
Would there be a fix soon? In My case, it is not a different file, but the variables are used from two different structs like this . A { name string } B{ A, age int}, C{A , color string}. Both B and C use A which uses name. But the golangci says name is not used. |
I've found this to happen when using files with periods in the name with as recent as I changed a file |
Still same with me |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue still appears to be present in the golangci-lint v1.44.0. Should, perhaps, |
Thank you for creating the issue!
Please include the following information:
golangci-lint --version
(or git commit if you don't use binary distribution)cat .golangci.yml
go version && go env
golangci-lint run -v
The problem happens when the given variables / types are defined in one file, and used in another in the same package.
I did a quick test to asses whether these were really unused, and here is the logic:
a. I took one of these, reported as unused:
b. commented it out in the file where it is defined
c. ran the linter again:
As expected, that returned errors about lfTf being undeclared:
I was able to recreate the issue for all of the objects reported by first check.
I noticed that megacheck used to have a similar problem and that you guys have fixed it previously:
#148
Would you mind looking at structcheck as well ?
Cause at the moment, I had to disable this linter in our pipeline, as it turns out all errors coming from it, happen to be false positive in our scenario (where we have some structure definitions in one file, that are then used in different files within the same package).
Kind regerads
moolibdensplk
The text was updated successfully, but these errors were encountered: