代码拉取完成,页面将自动刷新
#!/bin/bash
# Generate test coverage statistics for Go packages.
#
# Works around the fact that `go test -coverprofile` currently does not work
# with multiple packages, see https://code.google.com/p/go/issues/detail?id=6909
#
# Usage: coverage.sh [--html|--coveralls]
#
# --html Additionally create HTML report
# --coveralls Push coverage statistics to coveralls.io
#
set -e
workdir=.cover
profile="$workdir/cover.out"
mode=count
generate_cover_data() {
rm -rf "$workdir"
mkdir "$workdir"
for pkg in "$@"; do
f="$workdir/$(echo $pkg | tr / -).cover"
go test -covermode="$mode" -coverprofile="$f" "$pkg"
done
echo "mode: $mode" >"$profile"
grep -h -v "^mode:" "$workdir"/*.cover >>"$profile"
}
show_html_report() {
go tool cover -html="$profile" -o="$workdir"/coverage.html
}
show_csv_report() {
go tool cover -func="$profile" -o="$workdir"/coverage.csv
}
push_to_coveralls() {
echo "Pushing coverage statistics to coveralls.io"
echo $GOPATH
# ignore failure to push - it happens
goveralls -coverprofile="$profile" \
-service=github || true
}
generate_cover_data $(go list ./... | grep -v /vendor/)
show_csv_report
case "$1" in
"")
;;
--html)
show_html_report ;;
--coveralls)
push_to_coveralls ;;
*)
echo >&2 "error: invalid option: $1"; exit 1 ;;
esac
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。