Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

go

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?

like image 635
tugberk Avatar asked Nov 12 '14 18:11

tugberk


People also ask

What does exit status 1 mean?

The "Exit Code 1" is simply a "Generic Exit Code" which means the job failed and this can be for any reason.

What is exit status 2?

Exit code 2 signifies invalid usage of some shell built-in command. Examples of built-in commands include alias, echo, and printf.

What is exit status in Linux?

The exit status of an executed command is the value returned by the waitpid system call or equivalent function. Exit statuses fall between 0 and 255, though, as explained below, the shell may use values above 125 specially. Exit statuses from shell builtins and compound commands are also limited to this range.

What do exit codes mean?

An exit code or exit status is a number that is returned by an executable to show whether it was successful. This is also sometimes called a return code, or in some cases, an error code, although the terminology here may be slightly different.


1 Answers

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.

like image 61
JimB Avatar answered Sep 18 '22 13:09

JimB