-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathgoclean.sh
53 lines (43 loc) · 1.66 KB
/
goclean.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
# The script does automatic checking on a Go package and its sub-packages, including:
# 1. gofmt (http://golang.org/cmd/gofmt/)
# 2. goimports (https://github.com/bradfitz/goimports)
# 3. golint (https://github.com/golang/lint)
# 4. go vet (http://golang.org/cmd/vet)
# 5. race detector (http://blog.golang.org/race-detector)
# 6. test coverage (http://blog.golang.org/cover)
# ref. https://gist.github.com/hailiang/0f22736320abe6be71ce
set -e
#go get -v golang.org/x/lint/golint
#go get -v golang.org/x/tools/cmd/goimports
#go get -v ./...
# Automatic checks
#test -z "$(gofmt -l -w ./ | tee /dev/stderr)"
#test -z "$(goimports -l -w ./ | tee /dev/stderr)"
#test -z "$(golint ./... | tee /dev/stderr)"
#go vet ./...
#go test -race ./...
#go test -race ./campaign...
#go test -race ./mails...
#go test -race ./reader...
#go test -race ./utils...
# Run test coverage on each subdirectories and merge the coverage profile.
echo "mode: count" > coverage.cov
ls
# Standard go tooling behavior is to ignore dirs with leading underscors
for dir in $(find . -maxdepth 10 -not -path './.git*' -not -path '*/_*' -not -path './cmd' -not -path './cmd/docs' -not -path './sql' -type d);
do
if ls $dir/*.go &> /dev/null; then
go test -v -covermode=count -coverprofile=$dir/coverage.tmp $dir
if [ -f $dir/coverage.tmp ]
then
cat $dir/coverage.tmp | tail -n +2 >> coverage.cov
rm $dir/coverage.tmp
fi
fi
done
go tool cover -func coverage.cov
cat coverage.cov
# To submit the test coverage result to coveralls.io,
# use goveralls (https://github.com/mattn/goveralls)
# goveralls -covercoverage=coverage.cov -service=travis-ci