[ANN] errcheck - a tool for checking for unchecked errors

761 views
Skip to first unread message

Kamil Kisiel

unread,
Feb 24, 2013, 11:05:38 PM2/24/13
to golan...@googlegroups.com
The issue of unchecked error returns from functions has been discussed to death on the mailing list many times. The possibility of adding a mode to the vet tool to do it has come up, and the answer has always been "it should be possible when go/types is ready". Since the types package was recently added to tip I figured I would try a weekend hack to see if such a checker is possible. Turns out the answer is yes.

The result of several hours of hacking, interspersed with sessions of drumming an electronic music production, is errcheck:


It's very much bare-bones right now, but it does mostly work. You can run it your packages and it will tell you where you forgot to assign an error return to a variable or the null identifier. There's no knobs to tune as far ignoring things goes right now, but it ignores the fmt package entirely. It currently does not work with cgo packages (I'm not sure how to do that), and occasionally the type checking errors out (I'm not sure if that's my fault or bugs in go/types). 

There are a couple of flags for filtering the checking that you can read about in the README.

Please give it a try. Feedback and pull requests are always welcome :)

Dave Cheney

unread,
Feb 25, 2013, 2:57:38 AM2/25/13
to Kamil Kisiel, golan...@googlegroups.com
This is fantastic Kamil. Thank you. 
--
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...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Tamás Gulácsi

unread,
Feb 25, 2013, 12:26:11 PM2/25/13
to golan...@googlegroups.com
Greate tool!
Thanks!
Reply all
Reply to author
Forward
0 new messages