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 glide is installed and $GOPATH/bin is in your path.
|
|
|
|
# $ go get -u github.com/Masterminds/glide
|
|
|
|
# $ glide install
|
|
|
|
if [ ! -x "$(type -p glide)" ]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Make sure gometalinter is installed and $GOPATH/bin is in your path.
|
|
|
|
# $ go get -v github.com/alecthomas/gometalinter"
|
|
|
|
# $ gometalinter --install"
|
|
|
|
if [ ! -x "$(type -p gometalinter)" ]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
linter_targets=$(glide novendor)
|
|
|
|
|
2015-01-31 05:08:53 +01:00
|
|
|
# Automatic checks
|
2017-03-22 21:18:32 +01:00
|
|
|
test -z "$(gometalinter -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)"
|
2017-07-01 23:05:59 +02:00
|
|
|
go test -tags rpctest $linter_targets
|