Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bodyclose fails unexpected #49

Closed
zirain opened this issue Apr 26, 2023 · 1 comment
Closed

bodyclose fails unexpected #49

zirain opened this issue Apr 26, 2023 · 1 comment

Comments

@zirain
Copy link

zirain commented Apr 26, 2023

bodyclose will fails with following code:

        resp, err := client.Do(req)
	if err != nil {
		return
	}
	// lint will fail
	defer func(b io.ReadCloser) {
		_ = b.Close()
	}(resp.Body)

but it's ok with:

        resp, err := client.Do(req)
	if err != nil {
		return
	}
	// lint will fail
	 defer resp.Body.Close()
@zirain
Copy link
Author

zirain commented May 6, 2023

should change code to:

        resp, err := client.Do(req)
	if err != nil {
		return
	}
	defer func(b io.Closer) {
		_ = b.Close()
	}(resp.Body)

@zirain zirain closed this as completed May 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant