1#!/bin/bash 2# The script does automatic checking on a Go package and its sub-packages, including: 3# 1. gofmt (http://golang.org/cmd/gofmt/) 4# 2. golint (https://github.com/golang/lint) 5# 3. go vet (http://golang.org/cmd/vet) 6# 4. gosimple (https://github.com/dominikh/go-simple) 7# 5. unconvert (https://github.com/mdempsky/unconvert) 8# 9# gometalinter (github.com/alecthomas/gometalinter) is used to run each static 10# checker. 11 12set -ex 13 14# Make sure gometalinter is installed and $GOPATH/bin is in your path. 15# $ go get -v github.com/alecthomas/gometalinter" 16# $ gometalinter --install" 17if [ ! -x "$(type -p gometalinter.v2)" ]; then 18 exit 1 19fi 20 21linter_targets=$(go list ./...) 22 23# Automatic checks 24test -z "$(gometalinter.v2 -j 4 --disable-all \ 25--enable=gofmt \ 26--enable=golint \ 27--enable=vet \ 28--enable=gosimple \ 29--enable=unconvert \ 30--deadline=10m $linter_targets 2>&1 | grep -v 'ALL_CAPS\|OP_' 2>&1 | tee /dev/stderr)" 31GO111MODULE=on go test -tags="rpctest" $linter_targets 32