4 ms·
Putting aside discussions about Gos error handing and opinions about try and catch blocks, this specific problem (wrt the HTTP handler) can emulate the same cod
by laumars 4y ago
Putting aside discussions about Gos error handing and opinions about try and catch blocks, this specific problem (wrt the HTTP handler) can emulate the same code you’ve got above using a defer block.
var err error
defer func() {
if err != nil {
w.Write([]byte(err.Error())
}
}()