Handle Close errors for errcheck
Check http response body, websocket, and server connection Close return values to satisfy golangci-lint errcheck.
This commit is contained in:
1 parent
a3bd21d329
commit
a9e8cac0e5
2 files changed
+20
-4
No files matched your search
+15
-3
@@ -56,7 +56,11 @@ func getVkCreds(link string) (string, string, string, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer httpResp.Body.Close()
|
||||
defer func() {
|
||||
if closeErr := httpResp.Body.Close(); closeErr != nil {
|
||||
log.Printf("close response body: %s", closeErr)
|
||||
}
|
||||
}()
|
||||
|
||||
body, err := io.ReadAll(httpResp.Body)
|
||||
if err != nil {
|
||||
@@ -267,7 +271,11 @@ func getYandexCreds(link string) (string, string, string, error) {
|
||||
if err != nil {
|
||||
return "", "", "", err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
defer func() {
|
||||
if closeErr := resp.Body.Close(); closeErr != nil {
|
||||
log.Printf("close response body: %s", closeErr)
|
||||
}
|
||||
}()
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
body, _ := io.ReadAll(resp.Body)
|
||||
return "", "", "", fmt.Errorf("GetConference: status=%s body=%s", resp.Status, string(body))
|
||||
@@ -295,7 +303,11 @@ func getYandexCreds(link string) (string, string, string, error) {
|
||||
if err != nil {
|
||||
return "", "", "", fmt.Errorf("ws dial: %w", err)
|
||||
}
|
||||
defer conn.Close()
|
||||
defer func() {
|
||||
if closeErr := conn.Close(); closeErr != nil {
|
||||
log.Printf("close websocket: %s", closeErr)
|
||||
}
|
||||
}()
|
||||
|
||||
req1 := HelloRequest{
|
||||
UID: uuid.New().String(),
|
||||
|
||||
Reference in new issue
Block a user