add Go coverage helper function

This commit is contained in:
Tony Blyler 2020-12-31 12:11:07 -05:00
parent ff86d61df9
commit dfe35df892

View file

@ -0,0 +1,11 @@
if command -v go &> /dev/null; then
go_coverage() {
(
set -eo pipefail
local -r COVERAGE_OUT="$(mktemp)"
go test -cover -coverprofile="${COVERAGE_OUT}" ./...
go tool cover -func="${COVERAGE_OUT}"
rm -f "${COVERAGE_OUT}"
)
}
fi