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

Prevent resource leaks #253

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

amitkrout
Copy link

@amitkrout amitkrout commented May 19, 2023

$ make
[...]
golangci-lint run
common/errors_go13_test.go:45:18: response body must be closed (bodyclose)
        resp := r.Result()
                        ^
[...]

The linting tool has identified a potential issue with the code. It's error out that the response body obtained from r.Result() should be closed after its use to prevent resource leaks.

By using the defer statement, the resp.Body.Close() function will be executed when the surrounding function returns, ensuring the response body is always closed.

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

Successfully merging this pull request may close these issues.

1 participant