{"repo":"timakin/bodyclose","free":true,"listed":false,"github":"https://github.com/timakin/bodyclose","clone":"git clone https://github.com/timakin/bodyclose.git","description":"Analyzer: checks whether HTTP response body is closed and a re-use of TCP connection is not blocked.","language":"Go","stars":323,"topics":["golang","go","http","request","static-analysis","code-analysis","linter","linter-plugin"],"license":"MIT","category":"dev-tools","readme_excerpt":"bodyclose bodyclose is a static analysis tool which checks whether res.Body is correctly closed. Install You can get bodyclose by go get command. How to use bodyclose run with go vet as below when Go is 1.12 and higher. Options You can enable additional checks with the -check-consumption flag to also verify that response bodies are consumed: Handled Response Directive Use //bodyclose:handled on a function that fully handles every returned http.Response body before returning: Calls to an annotated function are skipped by both the close and consumption checks, including calls from another package. The directive works only for statically resolved function calls. Supported Consumption Patterns When -check-consumption is enabled, the following patterns are recognized as valid body consumption: - io.Copy(io.Discard, resp.Body) - io.ReadAll(resp.Body) - ioutil.ReadAll(resp.Body) (legacy) - json.NewDecoder(resp.Body) - bufio.NewScanner(resp.Body) - bufio.NewReader(resp.Body) Limitations and False Positives Note : Patterns not listed above may trigger false positives even when the body is properly consumed. Use //nolint:bodyclose to suppress warnings for custom consumption patterns that are not automatically detected. Example of suppressing false positives: Limitation : The analyzer does not detect execution order, so patterns where Close() is called before consumption (which would fail at runtime) are not specifically flagged. Legacy Usage (Go < 1.12) When Go is lower than 1.12, just","default_branch":null,"files":null,"tree":[],"storefront":"/r/timakin","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/timakin/bodyclose/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}