Skip to content

Instantly share code, notes, and snippets.

@tidwall
Created May 27, 2018 19:06
Show Gist options
  • Save tidwall/a9f9e92fc13a85c6cf047eeb02f8e787 to your computer and use it in GitHub Desktop.
Save tidwall/a9f9e92fc13a85c6cf047eeb02f8e787 to your computer and use it in GitHub Desktop.
Go cover helper with html output
# 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