Skip to content

Server crashed on log.Fatal with recovery middleware #2516

Closed Answered by aldas
Kirari04 asked this question in Q&A
Discussion options

You must be logged in to vote

This is because calling Fatal will cause application to exit.

https://github.com/golang/go/blob/08e35cc3347f97ef750fd21fbef1061b043580e4/src/log/log.go#L281-L285

// Fatal is equivalent to l.Print() followed by a call to os.Exit(1).
func (l *Logger) Fatal(v ...any) {
	l.Output(2, fmt.Sprint(v...))
	os.Exit(1)
}

p.s. any reasonably ok IDE can show you this - just hold down CTRL and left click on method call and you will be taken to (Goland) or you will see preview of (VScode) that method implementation.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Kirari04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants