Skip to content

Instantly share code, notes, and snippets.

@PetengDedet
Created November 19, 2021 08:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PetengDedet/ca336218c406b29bf69c04a0cbb731b2 to your computer and use it in GitHub Desktop.
Save PetengDedet/ca336218c406b29bf69c04a0cbb731b2 to your computer and use it in GitHub Desktop.
log.Fatal vs log.Panic
log.Fatal() log.Panic()
When to Use When something unexpected happened When something really unexpected happened
Use Case - Not enough arguments - can not access file - etc. - Not having enough disk space - Not being find file that previously accessed - etc.
Terminate Behavior Stops the program at the point where log.Fatal() called Immediately stops the Go program
Similar function Similar to call log.Print() followed by os.Exit(1) Similar to call log.Print() followed by panic()
Log Output Prints out custom message only Prints out the custom message and additional low level OS information
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment