On Monday, September 4, 2017 at 10:48:06 PM UTC+2, Tamás Gulácsi wrote: > > Why do you Prepare a statement if you don't reuse it? Just use a db.Exec.
Just wanted to show a pattern which I see very often in Go code. Its not a working example, and I am not asking for improvements in that code. But concretes aside: error handling IS important! > Yes it is. But as my example shows, it should not get annoying. > But if such code bothers you, create some helper type / function: see one > Andy+Brad pair programming video where they create an errWriter struct > which is an io.Writer, and just writes to the underlyin Write. Untill the > first error. From then on it always returns the fist error. > The problem with ANY error handling solution within the existing Go syntax will require one of three things: - Wrap the call which you need to check the error for - Wrap the check into a function, to save code lines - Do some tricks to check the error at the end of a block Neither one of these methods is satisfying for me. I need to be able to produce readable, concise code which does the right thing. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.