News for hackers. Stuff that matters.
Re:Errors are values by twotwotwo on Monday January 12, 2015 @09:06PM (#8877713)
> I really prefer the Java "force you to catch exception" model much more to this.

https://github.com/kisielk/errcheck/ will tell you if you silently discard the `err` value (though you can still explicitly assign it to _ to ignore). Seems worth using for a lot of projects.

Re:Errors are values by burke on Monday January 12, 2015 @09:39PM (#8877796)
We use errcheck for all the Go code we write at Shopify. In many cases, we compile the project using a script that fails if errcheck isn't clean, effectively turning into a "you are forced to catch the exception" sort of idea.

It's nice because it's still easy to ignore the err in certain circumstances (e.g. the occasional `_ = f.Close()`), but there's always a visual marker to remind you.

Re:Errors are values by jroesch on Monday January 12, 2015 @11:38PM (#8878170)
The above comments are just pointing out that the compiler should do this for you. It is great that there are third party tools for this, but a simple lint like this should come for free, especially when this is the endorsed error handling policy.
Re:Errors are values by enneff on Tuesday January 13, 2015 @05:54AM (#8879024)
Not everything belongs in the compiler. Go's "vet" tool might be the place for something like this. But, honestly, I have been writing Go code for 5 years and I can count the number of times that "didn't check the error" was the cause of a bug on one hand.
Re:Errors are values by twotwotwo on Wednesday January 14, 2015 @02:45PM (#8888535)
Agree on not in the compiler. A ton of folks seem to dig errcheck; having that sort of check in vet or in the Go distro somehow seems worthwhile. (Of course, if I feel that way, maybe I should put some effort where my mouth is and try and start on a patch. :)
Re:Errors are values by Intermernet on Monday January 12, 2015 @11:51PM (#8878213)
I'm actually quite surprised this functionality hasn't made it into "go vet" yet. It would be useful to be able to do this without a 3rd party utility (although all respect to kisielk for producing such a useful tool).
Re:Errors are values by rtpg on Tuesday January 13, 2015 @12:39AM (#8878346)
pleasantly surprised that you could write go tooling to check this, I hope the team is willing to pull things like this in.