The One Liner
echo "mode: count" > coverage.txt;for pkg in `find . -maxdepth 3 -path '*_test.go' -type f | xargs -I{} dirname {} | uniq`;do go test -covermode=count -coverprofile=temp.cov $pkg && tail -n +2 temp.cov >> coverage.txt || exit 1;rm temp.cov;done
Format
echo "mode: count" > coverage.txt
for pkg in `find . -maxdepth 3 -path '*_test.go' -type f | xargs -I{} dirname {} | uniq`
do
go test -covermode=count -coverprofile=temp.cov $pkg && tail -n +2 temp.cov >> coverage.txt || exit 1
rm temp.cov
done
I discover better practice !
echo "mode: count" > coverage.txt
for pkg in `go list -f="{{if .TestGoFiles}}{{.ImportPath}}{{end}}" ./...`
do
go test -covermode=count -coverprofile=temp.cov $pkg && tail -n +2 temp.cov >> coverage.txt || exit 1
done