Skip to content

Commit

Permalink
Minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
royroyee committed Aug 21, 2024
1 parent 89160e8 commit fa03206
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
7 changes: 2 additions & 5 deletions api/ftp/ftp.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ func UploadFile(ac *client.AlpaconClient, src []string, dest, username, groupnam
if err != nil {
return nil, err
}
err = writer.Close()
if err != nil {
return nil, err
}
defer func() { _ = writer.Close() }()
respBody, err := ac.SendMultipartRequest(uploadAPIURL, writer, requestBody)
if err != nil {
return nil, err
Expand Down Expand Up @@ -152,7 +149,7 @@ func DownloadFile(ac *client.AlpaconClient, src, dest, username, groupname strin
}
}

defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

respBody, err := io.ReadAll(resp.Body)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions api/websh/websh.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func OpenNewTerminal(ac *client.AlpaconClient, sessionResponse SessionResponse)
if err != nil {
utils.CliError("websocket connection faiied %v", err)
}
defer wsClient.conn.Close()
defer func() { _ = wsClient.conn.Close() }()

err = wsClient.runWsClient()
if err != nil {
Expand All @@ -124,7 +124,7 @@ func (wsClient *WebsocketClient) runWsClient() error {
if err != nil {
utils.CliError("websocket connection faiild %v", err)
}
defer term.Restore(int(os.Stdin.Fd()), oldState)
defer func() { _ = term.Restore(int(os.Stdin.Fd()), oldState) }()

inputChan := make(chan string, 1)

Expand Down
4 changes: 2 additions & 2 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (ac *AlpaconClient) sendRequest(req *http.Request) ([]byte, error) {
if err != nil {
return nil, err
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

contentType := resp.Header.Get("Content-Type")
// Check for non-empty and non-JSON content types. Empty content type allowed for responses without content (e.g., from PATCH requests).
Expand Down Expand Up @@ -206,7 +206,7 @@ func (ac *AlpaconClient) SendMultipartRequest(url string, multiPartWriter *multi
if err != nil {
return nil, err
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

contentType := resp.Header.Get("Content-Type")
// Check for non-empty and non-JSON content types. Empty content type allowed for responses without content (e.g., from PATCH requests).
Expand Down

0 comments on commit fa03206

Please sign in to comment.