diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-13 10:01:59 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-13 10:01:59 +0200 |
| commit | 44a426c883a2c448d40a19903c822d03e5cf70af (patch) | |
| tree | dbb1fe11db1993c2cac7daf1c9930e37f44b38d1 /internal/platforms/linkedin/oauth2/oauth2.go | |
| parent | cfddc5696f4956081630e3d394ef3d8c652af02e (diff) | |
chore: complete code quality audit fixesv1.2.6
- Fixed failing test in config_test.go (hardcoded date)
- Addressed unchecked error returns from Close() operations
- Refactored large functions to follow SRP (run.go and main.go)
- Added documentation to exported identifiers
- Fixed linting errors (error message capitalization, errcheck)
- Bumped version to v1.2.6
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 } } |
