diff options
Diffstat (limited to 'internal/platforms/linkedin/oauth2/oauth2.go')
| -rw-r--r-- | internal/platforms/linkedin/oauth2/oauth2.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/internal/platforms/linkedin/oauth2/oauth2.go b/internal/platforms/linkedin/oauth2/oauth2.go index 45cb9b7..b4d3bb3 100644 --- a/internal/platforms/linkedin/oauth2/oauth2.go +++ b/internal/platforms/linkedin/oauth2/oauth2.go @@ -41,7 +41,12 @@ func getOauthPersonID(token *oauth2.Token) (string, error) { if err != nil { return "", fmt.Errorf("Error making the request:%w", err) } - defer resp.Body.Close() + defer func() { + if err := resp.Body.Close(); err != nil { + // Log the error but don't fail the operation since we've already read the data + colour.Errorln("Error closing response body:", err) + } + }() body, _ := io.ReadAll(resp.Body) if resp.StatusCode != http.StatusOK { @@ -171,7 +176,10 @@ func WaitUntilURLIsReachable(url string) error { colour.Infofln("URL is not reachable: %v", err) } else { colour.Infofln("URL is reachable: %s - Status Code: %d", url, resp.StatusCode) - resp.Body.Close() + if err := resp.Body.Close(); err != nil { + // Log the error but don't fail the operation since we've already read the data + colour.Errorln("Error closing response body:", err) + } return nil } } |
