Skip to content

Go製の実行ファイルでカバレッジを計測する

This content is a draft and will not be included in production builds.

Go 1.20から追加された。

Terminal window
export "GOCOVERDIR=$(mktemp -d)"
trap 'rm -rf "$GOCOVERDIR"; exit 1' 1 2 3 15
go run -cover . -flag=std ./testdata/*
go tool covdata textfmt -i="$GOCOVERDIR" -o prof.out
go tool cover -html=prof.out
rm -rf "$GOCOVERDIR"