-
Notifications
You must be signed in to change notification settings - Fork 10
/
goclean.sh
46 lines (39 loc) · 1.62 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
#!/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
# 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 ./tradingdays...
go test -race ./twse...
go test -race ./utils...
#go test -race ./realtime...
# Run test coverage on each subdirectories and merge the coverage profile.
echo "mode: count" > coverage.cov
# Standard go tooling behavior is to ignore dirs with leading underscors
for dir in $(find . -maxdepth 10 -not -path './.git*' -not -path '*/_*' -not -path './realtime' -not -path './cmd/docs' -type d);
do
if ls $dir/*.go &> /dev/null; then
#go test -v --benchmem --bench=. -covermode=count -covercoverage=$dir/coverage.tmp $dir
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
# To submit the test coverage result to coveralls.io,
# use goveralls (https://github.com/mattn/goveralls)
# goveralls -covercoverage=coverage.cov -service=travis-ci