Created
May 27, 2018 19:06
-
-
Save tidwall/a9f9e92fc13a85c6cf047eeb02f8e787 to your computer and use it in GitHub Desktop.
Go cover helper with html output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# add this to your ~/.bash_profile or whatnot | |
go(){ | |
local r | |
if [[ $@ == "test -cover" ]]; then | |
r="$(command go test -coverprofile=/tmp/coverage.out)" | |
if [ "$r" != "" ]; then | |
printf "%s\n" "$r" | |
fi | |
if [[ "$r" == *"100.0%"* ]]; then | |
printf "🎉 \e[1mYou're pretty fucking awesome. Keep that shit up!\e[0m 🎉\n"; | |
else | |
go tool cover -html=/tmp/coverage.out -o /tmp/coverage.html | |
echo "details: file:///tmp/coverage.html" | |
fi | |
else | |
command go "$@" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment