3 ms·
There may be libraries that call panic. E.g., the templating library does that. In that case, I want something in the logs, not a termination of the service.
by tgv 2y ago
There may be libraries that call panic. E.g., the templating library does that. In that case, I want something in the logs, not a termination of the service.
- gizzlon 2y agoIIRC, the Must.. functions are typically used at program start, and in cases where you would like the program to stop. At least that's the way I've used it. For example to read and parse expected templates from disk. If they aren't there, there really is no reason to continue, it's just very very confusing. https://pkg.go.dev/html/template@go1.24.0#Must https://pkg.go.dev/html/template@go1.24.0#Must
- arccy 2y agothe template and regexp packages have Must variants that panic. They're intended to crash the program on init because of programmer error.