Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make go linters ignore vendor/?

Tags:

go

How do we make go vet, gofmt, and other Go linter tools ignore third-party files in vendor/, preferably with an accurate, cumulative exit status?

For example, would find . -name vendor -prune -o -name '*.go' -exec gofmt -s -w {} \; present a meaningful exit status?

like image 441
mcandre Avatar asked Nov 10 '16 15:11

mcandre


2 Answers

Here is what I use:

golint $(ls -d1 */ | sed s/\\//\\/.../g | grep -v -E "^vendor/" | tr "\n" " ")
like image 138
Csongor Halmai Avatar answered Oct 13 '22 16:10

Csongor Halmai


I usually do

go fmt $(go list ./... | grep -v /vendor/)
go test $(go list ./... | grep -v /vendor/)

But since I started using govendor discovered I can do the same using govendor with less typing

govendor fmt +l // +l is shorthand for local
like image 28
Havelock Avatar answered Oct 13 '22 16:10

Havelock