如何运行已编译的 Go 测试二进制文件?

huangapple go评论87阅读模式
英文:

How to run a compiled Go test binary?

问题

我通过运行go test -c ./model编译了一个Go测试库。根据Go文档,可以使用go run -exec xprog命令来运行它,但是当我尝试运行生成的model.test二进制文件时,我一直遇到错误。请问完整的命令是什么?

附注:我知道你可以使用不同的标志来编译和运行,但这不是我需要的。

英文:

I compiled a Go test library by running go test -c ./model. According to Go docs it can be run using go run -exec xprog command, however, I keep getting errors while trying to run my generated model.test binary. What is the full command here?

P.S I know you can use a different flag to compile and run but this is not what I need.

答案1

得分: 1

你可以像运行其他二进制文件一样运行它。例如,在shell中执行以下命令:

./model.test

测试结果将被写入标准输出,并且如果所有测试都通过,进程的退出代码将为0

英文:

You can run the binary the same as any other. For example, in the shell:

./model.test

Test results will be written to the standard output, and the process exit code will be 0 if all tests passed.

huangapple
  • 本文由 发表于 2023年2月23日 08:41:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/75539560.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定