侧边栏壁纸
  • 累计撰写 72 篇文章
  • 累计创建 91 个标签
  • 累计收到 10 条评论

目 录CONTENT

文章目录

golang单测覆盖率查询

Kunkka Wu
2022-06-10 / 0 评论 / 6 点赞 / 2552 阅读 / 0 字
温馨提示:
部分素材来自网络,若不小心影响到您的利益,请联系我们删除。

#!/usr/bin/env bash

function ut_cover() {
  go test -coverprofile cover.out ./...
  total=$(go tool cover -func=cover.out | tail -1)
  echo ${total}
  rm cover.out
  coverage=$(echo ${total} | grep -P '\d+\.\d+(?=\%)' -o) #如果macOS 不支持grep -P选项,可以通过brew install grep更新grep
}

ut_cover

```
6
  1. 支付宝打赏

    qrcode alipay
  2. 微信打赏

    qrcode weixin

评论区