Skip to content

Instantly share code, notes, and snippets.

@boseabhishek
Forked from Integralist/Panic vs os.Exit.md
Created January 26, 2024 12:56
Show Gist options
  • Save boseabhishek/3af06218b44577674cae0a76e171850a to your computer and use it in GitHub Desktop.
Save boseabhishek/3af06218b44577674cae0a76e171850a to your computer and use it in GitHub Desktop.
[Golang: panic vs os.Exit] #go #golang #panic

panic signals "the programmer has made a fundamental mistake and execution cannot continue safely", whereas os.Exit signals "the programmer has decided that the process should terminate here" — different meanings. Also, important difference in behavior: panic will unwind the callstack, which means it will call any pending defer statements; os.Exit will just do a hard kill, so it won't.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment