Skip to content

Instantly share code, notes, and snippets.

@henrahmagix
Created June 25, 2018 10:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save henrahmagix/286f3199c9e09832850c810c661b78c9 to your computer and use it in GitHub Desktop.
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
# 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