I am trying to implement dep
in my project. This is all working well but it also adds a vendor directory. I now need to update my tooling to ignore this directory or my vendored packages will be modified or I get false positives of warnings. I am currently using the following tooling:
These tools are also used in CI. I do want to keep autoformatting using goimports, but I am willing to start using gometalinter. I am not really looking for a solution using grep and find magic.
How can I make these tools ignore vendor/
?
In the case of goimports, the contract is given a valid Go file, return the same valid Go file formatted by gofmt, with exactly the imports needed for it to compile. In order to fulfill it, a possible solution could be: parse the file and find unresolved references (symbols not declared in that file),
Clone the repository to your plugins folder. Specify the path to the goimports binary in GoImports.sublime-settings. Add to your sublime keys the following command and whenever you want to run goimports hit F4. It will format/automatically adjust imports in the current go file.
goimports will use srcDir to load all Go files in the directory of the file to fix, and parse all of them: if using the recommended Go architecture, this should yield all the package files.
Command goimports updates your Go import lines, adding missing ones and removing unreferenced ones. $ go get golang.org/x/tools/cmd/goimports In addition to fixing imports, goimports also formats your code in the same style as gofmt so it can be used as a replacement for your editor's gofmt-on-save hook.
gometalinter has a "--vendor" flag to ignore the vendor folder. the flag passes the needed paramters to the underlying tools to ignore the folder.
so one solution would be to use only govet, golint und goimports with gometalinter
gometalinter --disable-all --enable=vet --enable=golint --enable=goimports --vendor ./...
another solution might be (copied from gist):
goimports -d $(find . -type f -name '*.go' -not -path "./vendor/*")
imho I would prefer the first solution. That way you could easily add other linters as needed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With