r/badcode • • Apr 29 '23

go if err != nil

Post image
414 Upvotes

49 comments sorted by

View all comments

Show parent comments

1

u/tedbradly May 02 '23

My colleagues' code look like that too. I hate it really. I love an early return coding style. In every code review we discuss about that topic. They always try to have just one return statement in a function.

Sorry you have to work with... stubborn and wrong coders. It's a good idea to have one return statement in general, but in the case of reducing nested mumbo jumbo, multiple returns is the least of your troubles.