3 ms·
log.Fatalln() does an os.Exit(1), it doesn't just cause that particular goroutine to stop[1]. log.Panicln() will also cause the entire program to exit unless th
by Thorrez 7y ago
log.Fatalln() does an os.Exit(1), it doesn't just cause that particular goroutine to stop[1]. log.Panicln() will also cause the entire program to exit unless there's a recover[2].
log.Println(err) would be better than returning err, because returning err makes people wrongly think the error is being handled somewhere, when in reality nothing is looking at the return value. Using defer for that seems a bit strange though.
[1] https://play.golang.org/p/wwiq1bYjwVH https://play.golang.org/p/wwiq1bYjwVH
[2] https://play.golang.org/p/MpzafFlBSfx https://play.golang.org/p/MpzafFlBSfx