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?
The "Exit Code 1" is simply a "Generic Exit Code" which means the job failed and this can be for any reason.
Exit code 2 signifies invalid usage of some shell built-in command. Examples of built-in commands include alias, echo, and printf.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With