Thursday 9 May 2019

Go language: Exit the program with given status code


'Exit(code int)' method of 'os' package used to exit the application with given status code.

Example
os.Exit(1)

App.java
package main

import (
 "fmt"
 "os"
)

func main() {

 fmt.Println("Hello World")

 os.Exit(1)

 fmt.Println("I am not going to print")
}

Output
Hello World
exit status 1


Previous                                                 Next                                                 Home

No comments:

Post a Comment