On Tue, Apr 4, 2017 at 12:38 AM, Joubin Houshyar <jhoush...@gmail.com>
wrote:
>
> Well, you've got bigger fish to fry here in your example above than
> worrying about call site snafus: you should be closing that opened file in
> the error case. Right?
>

I don't think so. First, from a "general go API hygiene" position, it
doesn't make sense to require to do *anything* to a returned value if a
non-nil error is returned. And second, if open(2) fails, there won't even
be anything returned that could be closed.

It seems to me neither Dave's (roughly: all bets are off if function
> returns error) nor Ian's (roughly: be extra hygienic) replies has satisfied
> you.
>

I don't know how you would come to that conclusion. Dave's messages didn't
satisfy me, because they did not actually have anything to do with the
question. Ian's reply did. He asked a follow-up question though, which I
answered.

But also, I wasn't asking for a question with an authoritative answer. I
was soliciting opinions. That kind of thing doesn't usually end once
someone gave theirs. And I find all the other (later) replies very useful.


> And as far as the being "hurtful" to users of your functions, if they are
> ignoring errors, and ignoring documentation, then they fully deserve
> spending a few extra cycles banging their heads against the wall. It a
> lesson worth learning.
>

This is an incredibly weird position to me. The reasons for not checking an
error might range from "they don't have the experience/knowledge" to "they
weren't careful enough at that time" and considering either to be deserving
of punishment seems very arrogant to me. It seems to say that you assume
both you always were an expert programmer and you never make any mistakes.

Making people's life easier when they made a mistake - even if it's their
fault - is a net positive; you lose nothing and their life gets easier.

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