Skip to content
/ closecheck Public

Static code analyzer for Go which checks whether a return value that implements io.Closer is correctly closed

License

Notifications You must be signed in to change notification settings

dcu/closecheck

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

closecheck

closecheck is a static code analyzer which checks whether a return value that implements io.Closer is correctly closed

Install

You can get closecheck by go get command.

$ go get -u github.com/dcu/closecheck

QuickStart

$ closecheck package/...

Analyzer

closecheck checks that a returned io.Closer is not ignored since that's a common cause of bugs and leaks in Go applications. Specially when dealing with *http.Response.Body

For example, the following code is reported as an error:

_, err := http.Get("https://www.google.com")
...

Because the response body must be closed.

The checker detects whether the returned struct has a field that implements io.Closer or not. In the previous case the *http.Response struct has a field called Body which implements io.Closer

About

Static code analyzer for Go which checks whether a return value that implements io.Closer is correctly closed

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages