add Go coverage helper function
This commit is contained in:
parent
ff86d61df9
commit
dfe35df892
1 changed files with 11 additions and 0 deletions
11
home/.zshrc.d/golang-helpers.zsh
Executable file
11
home/.zshrc.d/golang-helpers.zsh
Executable 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
|
Loading…
Reference in a new issue