Ah, I just re-read the thread subject: if *any* of the values are non-nil.  
Sorry for the misunderstanding.

On Friday, February 16, 2018 at 3:42:23 PM UTC-7, Paul Brousseau wrote:
>
> If all of the values are non-nil, then `retnn nil, err` would not return, 
> would it?  Did I miss something?
>
> On Friday, February 16, 2018 at 2:38:05 PM UTC-7, Nathan Fisher wrote:
>>
>> Hi All,
>>
>> I've been contemplating alternative methods to address the "boiler plate" 
>> of error handling in Go. One of the main benefits I see to the current 
>> approach is that indentation highlights exception paths vs the success 
>> path. From a readability perspective I can see the benefit of this 
>> approach. It allows a reader to efficiently scan a function.
>>
>> One problem I see with the approach however is that it results in a lot 
>> of vertical expansion in the code. If you take a fail-fast and return such 
>> as the following it requires 4 lines of code for every check or worse 
>> people ignore the error with an underscore.
>>
>> r, err := os.Open("blah.txt")
>> if err != nil {
>>     return nil, err
>> }
>>
>> What I've been thinking about is a return statement that will return only 
>> if all of the values are non-nil/blank.
>>
>> The statement would enable you to replace the above with a single return 
>> as follows;
>>
>> r, err := os.Open("blah.text")
>> retnn nil, err
>>
>> I'm not wedded to the statement name retnn but more the general principle.
>>
>> Thoughts?
>>
>> Nathan
>>
>

-- 
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.

Reply via email to