github.com/dashpay/godash@v0.0.0-20160726055534-e038a21e0e3d/goclean.sh (about) 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. race detector (http://blog.golang.org/race-detector) 7 # 5. test coverage (http://blog.golang.org/cover) 8 9 set -ex 10 11 # Automatic checks 12 test -z "$(go fmt $(glide novendor) | tee /dev/stderr)" 13 test -z "$(for package in $(glide novendor); do golint $package; done | grep -v 'ALL_CAPS\|OP_\|NewFieldVal' | tee /dev/stderr)" 14 test -z "$(go vet $(glide novendor) 2>&1 | tee /dev/stderr)" 15 env GORACE="halt_on_error=1" go test -v -race $(glide novendor) 16 17 # Run test coverage on each subdirectories and merge the coverage profile. 18 19 set +x 20 echo "mode: count" > profile.cov 21 22 # Standard go tooling behavior is to ignore dirs with leading underscores. 23 for dir in $(find . -maxdepth 10 -not -path '.' -not -path './.git*' \ 24 -not -path '*/_*' -not -path './cmd*' -not -path './release*' \ 25 -not -path './vendor*' -type d) 26 do 27 if ls $dir/*.go &> /dev/null; then 28 go test -covermode=count -coverprofile=$dir/profile.tmp $dir 29 if [ -f $dir/profile.tmp ]; then 30 cat $dir/profile.tmp | tail -n +2 >> profile.cov 31 rm $dir/profile.tmp 32 fi 33 fi 34 done 35 36 # To submit the test coverage result to coveralls.io, 37 # use goveralls (https://github.com/mattn/goveralls) 38 # goveralls -coverprofile=profile.cov -service=travis-ci