Skip to content

Commit d1964e5

Browse files
authored
Fix lint errors of io.Close() (#270)
* Check io.Close() errors * Fix
1 parent 7b8a156 commit d1964e5

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

e2e_test/client/client.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ func Get(url string) (int, string, error) {
3030
if err != nil {
3131
return 0, "", fmt.Errorf("could not send a request: %w", err)
3232
}
33-
defer resp.Body.Close()
33+
defer func() {
34+
if err := resp.Body.Close(); err != nil {
35+
panic(err)
36+
}
37+
}()
3438
b, err := io.ReadAll(resp.Body)
3539
if err != nil {
3640
return resp.StatusCode, "", fmt.Errorf("could not read response body: %w", err)

server.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ func receiveCodeViaLocalServer(ctx context.Context, cfg *Config) (string, error)
1919
if err != nil {
2020
return "", fmt.Errorf("could not start a local server: %w", err)
2121
}
22-
defer localServerListener.Close()
22+
defer func() {
23+
// The listener may be closed by the server. No need to check the error.
24+
_ = localServerListener.Close()
25+
}()
2326

2427
if cfg.OAuth2Config.RedirectURL == "" {
2528
var localServerURL url.URL

0 commit comments

Comments
 (0)