static analysis tool for detecting unclosed io.Closer's

251 views
Skip to first unread message

Brian Sorahan

unread,
Dec 15, 2017, 1:15:15 PM12/15/17
to golang-nuts
I'm thinking something like what I described in the subject line could be useful.
Does anyone know if there is one out there? I haven't been able to find one.
Thank you!

howar...@gmail.com

unread,
Dec 20, 2017, 10:42:55 AM12/20/17
to golang-nuts
In the absence of an affirmative, I'll just say that I did a search of my own. 

This site:
lists a bunch of static analysis tools for go.

https://github.com/alecthomas/gometalinter has another list, and will run them for you. They have binary packages now at https://github.com/alecthomas/gometalinter/releases that include the linters they can run.

I wrote a minimal program that has the condition of opening an os.File, which is an os.Closer, and not explicitly closing it. None of them complained about this minimal program, so it is reasonable to assume that none of the static analysis tools on the gometalinter list check for that.


Brian Sorahan

unread,
Dec 28, 2017, 11:58:06 AM12/28/17
to golang-nuts
That seems like a decent affirmation! Thanks.

Fabien

unread,
Jan 2, 2018, 9:02:19 AM1/2/18
to golang-nuts
Hello,

Detecting all unclosed Closers in any case sounds a bit undecidable to me (sounds like the halting problem). But detecting some of them would be feasible.
Reply all
Reply to author
Forward
0 new messages