-
Notifications
You must be signed in to change notification settings - Fork 267
How to use gometaliner for projects with go modules and no vendor? #562
Comments
|
I am having the same issue. I do have a vendor directory but I'm simply running |
I believe you may be misunderstanding the problem. The errors above are failures to load the source, not lint errors. Ignoring the errors is not what you want, because they indicate that linting is not being performed due to a failure to load the source. If you were to ignore them you would not be linting the source files. This is unfortunately not obvious from the errors returned by most linters (or at least not from how they are printed by gometalinter). I just started trying out go1.11. What I've done so far is something like this:
I believe that is working correctly, but I haven't done much work to verify that all lint problems are being caught. |
It won't work, what I had to do was create a script called #!/bin/bash
[[ "$DEBUG" ]] && set -x
set -e
mod=$GO111MODULE
sudo rm -rf ~/.go
export GO111MODULE=off
go get -u github.com/alecthomas/gometalinter
gometalinter --fast --install
if [[ "$mod" == "on" ]] || ([[ "$mod" == "auto" ]] && [[ -f "go.mod" ]]); then
export GO111MODULE=$mod
go mod download
mods=$(cat go.mod | grep -E '^(\t|\s)+' | grep -v '// indirect' | sed -e 's/^[[:space:]]*//g')
echo "$mods" | while read l; do
d=$(printf "$l" | awk '{ print $1 }')
GO111MODULE=off go get -u "$d"
done
else
go get -u ./...
fi |
FYI this is deprecated and will stop working eventually. |
We used I don't have time to research a complete fix, but it would be great to have the support for Go 1.11 modules eventually. I'd be really happy even for partial support, eg. if we could enable just a few checks and add others later. Please, let me know if I can help somehow. Is there a migration strategy/list of supported checks anywhere? Thank you! |
go imports now supports modules, so it's only a matter of time before dependencies of gometalinter do too, I would assume pretty soon now that Go team is actively making sure modules support is upstream in the libs a lot of this stuff relies on. |
@pkopac you can work in GOPATH and use |
To be clear, whether a linter does or does not work with modules has nothing to do with gometalinter. The upstream tools need to be modified to support modules. You can track the official Go issue tracking various tool's here. If a tool supports modules and has not been re-vendored into gometalinter, please send a PR to do so. |
I think you need to a bulk update for this - I just went to try out gometalinter, but so many of the linters failed due to not working with Golang Modules that it's not going to be possible to integrate it. Linters like errcheck have recently been updated to work with Golang Modules, and there is a lot of active work on this issue. I don't know if OSS contributors will update all the linters - can you do a bulk update? Would be super appreciated. |
Currently, I have a repo which uses go modules and does not vendor its dependencies.
When running
gometalinter
, I get the following errors:And this is because linters go and lint the cached versioned of dependencies specified in
go.mod
andgo.sum
.Is there any way we can exclude these dependencies from being linted the same way we ignore
vendor
path?The text was updated successfully, but these errors were encountered: