« Back to Index

Go: panic vs os.Exit

View original Gist on GitHub

Tags: #go #guides

Panic vs os.Exit.md

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.