Exit Process in Go

Posted by yhuang
Public (Editable by Users)

Use os.Exit to immediately exit with a given status.

Go
Edit
package main

import (
    "fmt"
    "os"
)

func main() {

    // defers will not be run when using os.Exit, so this fmt.Println will never be called.
    defer fmt.Println("!")

    os.Exit(3)
}