Standard library / log
log.Logger.Fatal()
Write a message then call os.Exit(1). Deferred functions do not run. Avoid this in reusable libraries. Expected stdout: 'hello\n'. Expected exit status 1; run only as a standalone process.
Formal Syntax & Structure
go syntaxgo
func (l *Logger) Fatal(v ...any)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| v | ...any | Values to log or convert. |
Working Example
Example Snippetgo
package main
import ( "fmt" "log" "os")
func main() { l := log.New(os.Stdout, "", 0); defer fmt.Println("not executed"); l.Fatal("hello") }