Skip to content

Commit c8704bc

Browse files
committed
fix lint
1 parent c1ad1ce commit c8704bc

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

internal/lambdalabs/v1/errors.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"github.com/cenkalti/backoff/v4"
1313
)
1414

15-
func handleAPIError(ctx context.Context, resp *http.Response, err error) error {
15+
func handleAPIError(_ context.Context, resp *http.Response, err error) error {
1616
body := ""
1717
e, ok := err.(openapi.GenericOpenAPIError)
1818
if ok {

pkg/ssh/ssh.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ func ConnectToHost(ctx context.Context, config ConnectionConfig) (*Client, error
3131
dial: d.DialContext,
3232
privateKey: config.PrivKey,
3333
}
34+
fmt.Printf("local_ip: %s, public_ip: %s\n", localIP, publicIP)
3435
err := sshClient.Connect(ctx)
3536
if err != nil {
3637
return nil, fmt.Errorf("failed to connect: %w", err)
@@ -96,7 +97,11 @@ func (c *Client) runCommand(ctx context.Context, cmd string) (string, string, er
9697
if err != nil {
9798
return "", "", fmt.Errorf("failed to create session, try a new connection: %w", err)
9899
}
99-
defer sess.Close()
100+
defer func() {
101+
if err := sess.Close(); err != nil {
102+
fmt.Printf("failed to close session: %v\n", err)
103+
}
104+
}()
100105

101106
var stdOutBuffer bytes.Buffer
102107
sess.Stdout = &stdOutBuffer
@@ -404,7 +409,11 @@ func GetLocalIP(ctx context.Context) (net.IP, error) {
404409
if err != nil {
405410
return nil, fmt.Errorf("failed to dial for local IP: %w", err)
406411
}
407-
defer conn.Close()
412+
defer func() {
413+
if err := conn.Close(); err != nil {
414+
fmt.Printf("failed to close connection: %v\n", err)
415+
}
416+
}()
408417

409418
localAddr, ok := conn.LocalAddr().(*net.UDPAddr)
410419
if !ok {
@@ -442,7 +451,11 @@ func GetPublicIPStr(ctx context.Context) (string, error) {
442451
if err != nil {
443452
return "", fmt.Errorf("failed to get public IP: %w", err)
444453
}
445-
defer resp.Body.Close()
454+
defer func() {
455+
if err := resp.Body.Close(); err != nil {
456+
fmt.Printf("failed to close response body: %v\n", err)
457+
}
458+
}()
446459

447460
ip, err := io.ReadAll(resp.Body)
448461
if err != nil {

0 commit comments

Comments
 (0)