Skip to content

Commit

Permalink
lib: ssh: Fix lint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ish-hcc committed Dec 4, 2024
1 parent b033a3a commit 38f7715
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions server/lib/ssh/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ func (o *SSH) RunBenchmark(connectionInfo model.ConnectionInfo, types string) (s
logger.Println(logger.ERROR, true, "Failed to SFTP Connect: "+err.Error())
return "", err
}
defer client.Close()
defer func() {
_ = client.Close()
}()

dstPath := "/tmp/"
files := []string{"sourceFiles/milkyway", "sourceFiles/milkyway.sh"}
Expand Down Expand Up @@ -226,7 +228,9 @@ func (o *SSH) copyFileToSFTP(client *sftp.Client, file, dstPath string) error {
logger.Println(logger.ERROR, true, "SSH: Failed to create destination file: "+err.Error())
return err
}
defer dstFile.Close()
defer func() {
_ = dstFile.Close()
}()

logger.Println(logger.DEBUG, true, "SSH: Copying "+file+" to "+dstFilePath)
if _, err := io.Copy(dstFile, bytes.NewReader(fileContents)); err != nil {
Expand Down Expand Up @@ -355,7 +359,9 @@ func (o *SSH) RunCmd(cmd string) (string, error) {
if err != nil {
return "", fmt.Errorf("failed to create session: %s", err)
}
defer session.Close()
defer func() {
_ = session.Close()
}()

var output, stderr bytes.Buffer
session.Stdout = &output
Expand Down

0 comments on commit 38f7715

Please sign in to comment.