-
Notifications
You must be signed in to change notification settings - Fork 137
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
Support go modules #148
Support go modules #148
Conversation
Use golang.org/x/tools/go/packages to load and type check packages. This provides support for projects using go modules to also be able to use errcheck. Tests for vendored packages must be run in a GOPATH.
errcheck can now support packages importing "C", though there are limitations with versions of Go that are earlier than Go 1.11.
Hi Suzy, thanks very much for this update! Based on the tests it looks like this will only work on Go 1.9 or above? Since we have tagged releases I'm fine with dropping support for 1.8 and earlier but the Readme should probably be updated to indicate that. |
A couple of notes on the failed tests (including a couple of questions for you): Type check errors:
Support for < Go 1.9:
|
I think it's better not to print the messages to os.Stderr, I don't really think they provide much for the user to act on and will probably just create confusion. |
As far as errors in type checking the initial package, I think it's better to fail by default. We could provide a flag that allows you to continue checking even if the type checking fails but I think it should not be enabled by default. |
If there are type checking errors in the initial packages, do not continue with checking. Stop early to avoid a situation where there are false negatives because the whole program could not be fully checked for unchecked errors.
Hey Kamil, I made the changes we discussed (bailing early with type check errors in initial packages and not printing all type check errors to stderr) and I'm going to look into the breaking issue at tip and I'll give you an update when I know more! |
Looks like it's passing now. Do you think this could be made to work for 1.8? or does that just need to be dropped? I assumed the errors in the tests were because of incompatibilities there but it seems it was actually the type checking errors, which should now be fixed. |
Ok, I'll run the tests back to Go 1.7 to see if the issue was fixed. I believe that a change to the go command between Go 1.8 and 1.9 may have broken it, which is a different issue than the type checking errors. |
The incompatibility with Go < 1.9 is still there, but the other issues have been resolved. I pushed one final commit just to run the main test on the _test files as well. |
Great. Thanks very much for your contribution! |
@kisielk - can you confirm that we can mark |
Should be able to get this running again by updating
|
@suzmue have sent you a PR against your branch 👍 |
Oh no looks like this was reverted! getting errcheck onto go modules would be really nice :) |
yup that would be nice |
…with-gopackages"" This reverts commit 1787c4b.
…with-gopackages"" This reverts commit 1787c4b.
…with-gopackages"" This reverts commit 1787c4b.
Use golang.org/x/tools/go/packages to load and type check packages.
This provides support for projects using go modules to also be able to
use errcheck.
errcheck can support packages that import "C", though there are
limitations when run with versions of Go that are earlier than Go 1.11.
There is also support in go/packages for finding the package that "contains" a file, so should be easy to add support for #106.