Skip to content

Instantly share code, notes, and snippets.

@toefel18
Created December 16, 2016 21:37
Show Gist options
  • Save toefel18/77dcdf892b35dcb955ececc784dbd91f to your computer and use it in GitHub Desktop.
Save toefel18/77dcdf892b35dcb955ececc784dbd91f to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -e
# clear coverage.out
cp /dev/null coverage.out
for d in $(go list ./... | grep -v vendor); do
go test -race -coverprofile=profile.out -covermode=atomic $d
if [ -f profile.out ]; then
cat profile.out >> coverage.out
rm profile.out
fi
done
# remove duplicate lines (mode: count is present in each package)
awk '!a[$0]++' coverage.out > cover-profile.out
go tool cover -html=cover-profile.out -o coverage.html
rm coverage.out cover-profile.out
@toefel18
Copy link
Author

This script creates a single HTML file with the coverage of your project, per source file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment