|
|
|
|
|
by codo2
3988 days ago
|
|
To make the code simpler to read, I would suggest removing a bunch of "else {", like the ones on lines 84, 112 and 119 of main.go. When you have something like: if err != nil {
return err
} you don't need to put a else after the closing }. |
|
Choices like that are 100% personal preference, and belief of which is "better" again is personal opinion.
Foe the counter argument; I find it far more readable to follow the if/else blocks, than to rely on identifying which if blocks contain return statements.
Personally, I prefer a step further, keeping all if/else blocks and using a variable inside the method to track the return value, with a single return statement at the end of the method.
There are plenty of blogs and articles debating for or against every permutation of this. But in the end, it really doesn't matter one bit whether there's an else statement on line X Y and Z.