英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论