将 go 测试覆盖率输出发送到 stdout - 将其发送到 S3

Send go test coverage output to stdout - send it to S3

我想将 go test -c 的 html 发送到标准输出,这样我就可以从 S3 静态资产服务器提供结果 HTML。

像这样:

arti_fact="s3://cm-html/cm-api/$commit_sha"

go test -coverprofile cover.out .
go tool cover -html=cover.out -o /dev/stdout  | aws s3 cp - "$arti_fact"

有没有不使用 -o /dev/stdout 就可以写入标准输出的方法?

我认为将 golang 代码覆盖率信息发送到 S3/GCS 的方式是这样的:

go test -coverprofile cover.out .
go tool cover -html=cover.out -o /dev/stdout  | gsutil cp - gs://my-bucket/foo

如果没有临时文件也能做到这一点,那就太好了。类似于:

go test -coverprofile '/dev/stdout'  | 
go tool cover -html='/dev/stdin' -o '/dev/stdout'  | 
gsutil cp - 'gs://my-bucket/foo'