如何在执行os.Exit(1)时禁用”退出状态1″?

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

How to disable "exit status 1" when executing os.Exit(1)

问题

在我的一个Go项目中,我运行了os.Exit(1),它会打印出exit status 1。我该如何禁止打印这个消息?

英文:

In one of my go projects, I run os.Exit(1) and it prints out exit status 1. How can I disable this message to be printed?

答案1

得分: 80

禁用该消息,不要使用go run

go run是一个方便地将一个或多个Go文件编译到临时位置,执行二进制文件并进行清理的工具。您的可执行文件在子进程中运行,并且go工具会为您报告退出状态。

英文:

To disable the message, don't use go run.

go run is a tool to conveniently compile one or more go files into a temporary location, execute the binary, and clean up. Your executable is run in a sub-process, and the go tool is reporting the exit status for you.

huangapple
  • 本文由 发表于 2014年11月13日 02:18:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/26893774.html
匿名

发表评论

匿名网友

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

确定