通常go list比find这里更有帮助:$ go list ./... arp242.net/trackwallarp242.net/trackwall/cmdlinearp242.net/trackwall/vendor/arp242.net/sconfigarp242.net/trackwall/vendor/bitbucket.org/pkg/inflect[..trim..]如您所见,这将列出当前目录中的所有包名称。要过滤vendor我们可以使用的目录grep:$ go list ./... | grep -v /vendor/arp242.net/trackwallarp242.net/trackwall/cmdline如果您想运行多个 linter,报告所有错误,并且0仅在成功时返回,您可以使用循环和状态变量:#!/bin/shst=0for pkg in $(go list ./... | grep -v /vendor/); do echo "==> $pkg" go vet "$pkg" [ $? -ne 0 ] && st=1 golint "$pkg" [ $? -ne 0 ] && st=1 # gofmt works on files, not packages gofmt -d "${f#arp242.net/trackwall}"*.go [ $? -ne 0 ] && st=1doneexit $st这将输出如下内容:==> arp242.net/trackwallhttp.go:71: database/sql.NullString composite literal uses unkeyed fieldsexit status 1/home/martin/gocode/src/arp242.net/trackwall/http.go:70:2: don't use ALL_CAPS in Go names; use CamelCase/home/martin/gocode/src/arp242.net/trackwall/http.go:75:9: if block ends with a return statement, so drop this else and outdent its block==> arp242.net/trackwall/cmdlineExit 1当然,你不是第一个遇到这个问题的人,而且有些工具基本上和上面一样,除了更好。gometalinter可能是最著名的,我建议您使用它。它包括一个--vendor忽略供应商目录的开关:$ go get -u github.com/alecthomas/gometalinter$ gometalinter --vendor ./...helpers.go:25:1:warning: realpath is unused (deadcode)http.go:32:1:warning: _list is unused (deadcode)[..trim..]