2015-01-31 05:08:53 +01:00
|
|
|
#!/bin/bash
|
|
|
|
# The script does automatic checking on a Go package and its sub-packages, including:
|
|
|
|
# 1. gofmt (http://golang.org/cmd/gofmt/)
|
2016-05-06 17:47:53 +02:00
|
|
|
# 2. golint (https://github.com/golang/lint)
|
|
|
|
# 3. go vet (http://golang.org/cmd/vet)
|
2016-11-21 16:17:32 +01:00
|
|
|
# 4. gosimple (https://github.com/dominikh/go-simple)
|
|
|
|
# 5. unconvert (https://github.com/mdempsky/unconvert)
|
2016-11-02 23:36:32 +01:00
|
|
|
#
|
2016-11-21 16:17:32 +01:00
|
|
|
# gometalinter (github.com/alecthomas/gometalinter) is used to run each static
|
|
|
|
# checker.
|
2015-01-31 05:08:53 +01:00
|
|
|
|
2015-04-14 21:13:13 +02:00
|
|
|
set -ex
|
2015-01-31 05:08:53 +01:00
|
|
|
|
2016-12-09 23:06:51 +01:00
|
|
|
# Make sure gometalinter is installed and $GOPATH/bin is in your path.
|
|
|
|
# $ go get -v github.com/alecthomas/gometalinter"
|
|
|
|
# $ gometalinter --install"
|
2018-05-16 05:01:58 +02:00
|
|
|
if [ ! -x "$(type -p gometalinter.v2)" ]; then
|
2016-12-09 23:06:51 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2018-11-30 02:45:40 +01:00
|
|
|
linter_targets=$(go list ./...)
|
2016-12-09 23:06:51 +01:00
|
|
|
|
2015-01-31 05:08:53 +01:00
|
|
|
# Automatic checks
|
2018-05-16 05:01:58 +02:00
|
|
|
test -z "$(gometalinter.v2 -j 4 --disable-all \
|
2016-11-02 23:36:32 +01:00
|
|
|
--enable=gofmt \
|
|
|
|
--enable=golint \
|
|
|
|
--enable=vet \
|
2016-11-03 05:53:07 +01:00
|
|
|
--enable=gosimple \
|
2016-11-03 06:04:28 +01:00
|
|
|
--enable=unconvert \
|
2017-03-22 21:18:32 +01:00
|
|
|
--deadline=10m $linter_targets 2>&1 | grep -v 'ALL_CAPS\|OP_' 2>&1 | tee /dev/stderr)"
|
2018-11-30 02:45:40 +01:00
|
|
|
GO111MODULE=on go test -tags="rpctest" $linter_targets
|