Tell Goland to go fuck itself with the unhandled errors in close

This commit is contained in:
jordi fita mas 2023-02-27 12:55:18 +01:00
parent 2ef75efda8
commit bc7ed0f06f
1 changed files with 8 additions and 2 deletions

View File

@ -92,12 +92,12 @@ func ServeInvoice(w http.ResponseWriter, r *http.Request, params httprouter.Para
if err != nil {
panic(err)
}
defer stdout.Close()
defer mustClose(stdout)
if err = cmd.Start(); err != nil {
panic(err)
}
go func() {
defer stdin.Close()
defer mustClose(stdin)
mustRenderAppTemplate(stdin, r, "invoices/view.gohtml", invoice)
}()
w.Header().Set("Content-Type", "application/pdf")
@ -113,6 +113,12 @@ func ServeInvoice(w http.ResponseWriter, r *http.Request, params httprouter.Para
}
}
func mustClose(closer io.Closer) {
if err := closer.Close(); err != nil {
panic(err)
}
}
type invoice struct {
Number string
Slug string