cover参数


go test -cover ...

会输出测试覆盖率

coverprofile参数


go test -coverprofile=coverage.out

Go会将测试结果输出的 coverage.out 文件中。然后,可使用go tool查看结果:


go tool cover -html=size_coverage.out