July 2019
Intermediate to advanced
458 pages
12h 12m
English
Exit codes are the way in which a process notifies its parent about its status after terminating. In order to return any exit status from the current process, there is one function that does the job in a straightforward way: os.Exit.
This function takes one argument, that is, an integer, and represents the exit code that will be returned to the parent process. This can be verified using a simple program, as shown in the following code:
package mainimport ( "fmt" "os")func main() { fmt.Println("Hello, playground") os.Exit(1)}
The full example is available at https://play.golang.org/p/-6GIY7EaVD_V.
The exit code, 0, is used when the application is executed successfully. Any other exit code symbolizes some type of error that ...
Read now
Unlock full access