Comments (7)
another one:
package main
import (
"net/http"
)
func main() {
resp, _ := http.Get("https://example.com")
defer func() {
_ = resp.Body.Close()
}()
}
from bodyclose.
And another one:
resp, err := c.do(req)
if err != nil {
return nil, err
}
defer func() { log.HandleError(resp.Body.Close()) }()
from bodyclose.
Thank you for your reports and I'm sorry for being late to supoort.
I'll fix them all.
from bodyclose.
thanks, and thanks for working on this I think it's really really really needed and will solve a very common issue, even in production
from bodyclose.
@dcu
Now I fixed all of them. And test cases below passed!
https://github.com/timakin/bodyclose/blob/master/passes/bodyclose/testdata/src/a/issue3.go
from bodyclose.
I can't fully confirm that the fix addresses all items. I still see about 80% of false negatives on a repo of mine. One example:
resp, err := t.C.Do(req)
require.NoError(t, err)
defer func() { require.NoError(t, resp.Body.Close()) }()
It's the same pattern of my previous example, just a different wrapper function.
from bodyclose.
I created new issues for cases I found
from bodyclose.
Related Issues (20)
- False positive: if function returns io.ReadCloser
- False positive with a retry for
- False positive with body close inside separate function HOT 11
- what zbout joining revive?
- Is this project still maintained? I want to add some new features to pr
- global resp cause check panic
- SSA and generics (go1.18) HOT 5
- false positive when close is in another package HOT 1
- False Positive when http.Response from a function HOT 2
- Check both closing and consuming the response body
- Bump golang.org/x/tools to v0.7.0 (as minimum) and make new tag
- False positive when using `httptest.NewRecorder()`
- bodyclose fails unexpected HOT 1
- conflicts with errcheck?
- Close in another function's defer function is not handled correctly
- False positive when using `http.NewResponseController(rw)`
- Generated code by ent cause check panic HOT 1
- Request: tag a version
- normalize CLI
- Detect if the body is closed in all code branches
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bodyclose.