Created
June 25, 2018 10:03
-
-
Save henrahmagix/286f3199c9e09832850c810c661b78c9 to your computer and use it in GitHub Desktop.
Open a browser window showing coverage for every go package in the current directory
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
# Assumes you are inside your GOPATH | |
for pkg in $(go list ./...); do | |
curr_dir_as_pkg=${PWD/$GOPATH\/src\//} | |
pkd_dir=${pkg/$curr_dir_as_pkg/} | |
if [ -z "$pkd_dir" ]; then | |
continue | |
fi | |
pkg_dir=${pkd_dir/\//} | |
name=${pkd_dir//\//-} | |
covfile=coverage$name.out | |
go test -coverprofile=$covfile ./$pkg_dir | |
go tool cover -html=$covfile | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment