Skip to content

Commit

Permalink
fix go vet errors with Go 1.24 (#5651) (#5684)
Browse files Browse the repository at this point in the history
(cherry picked from commit 11cb0a9)

Co-authored-by: Mauri de Souza Meneguzzo <[email protected]>
  • Loading branch information
mergify[bot] and mauri870 authored Oct 3, 2024
1 parent d93015e commit f067c92
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion internal/pkg/agent/application/monitoring/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (h *apiHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {

}

writeResponse(w, unexpectedErrorWithReason(err.Error()))
writeResponse(w, unexpectedErrorWithReason("%s", err.Error()))
}
}

Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/agent/vault/aesgcm/aesgcm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,12 @@ func TestEncryptDecryptHex(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
enc, err := EncryptHex(tc.key, tc.data)
if !errors.Is(tc.err, err) {
t.Fatalf(cmp.Diff(tc.err, err))
t.Fatal(cmp.Diff(tc.err, err))
}

dec, err := DecryptHex(tc.key, enc)
if !errors.Is(tc.err, err) {
t.Fatalf(cmp.Diff(tc.err, err))
t.Fatal(cmp.Diff(tc.err, err))
}

if len(tc.data) == 0 {
Expand Down
6 changes: 3 additions & 3 deletions internal/pkg/cli/confirm.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ func Confirm(prompt string, def bool) (bool, error) {
}

func confirm(r io.Reader, out io.Writer, prompt string, def bool) (bool, error) {
options := " [Y/n]"
options := "[Y/n]"
if !def {
options = " [y/N]"
options = "[y/N]"
}

reader := bufio.NewScanner(r)
for {
fmt.Fprintf(out, prompt+options+":")
fmt.Fprintf(out, "%s %s:", prompt, options)

if !reader.Scan() {
break
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/cli/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func ReadInput(prompt string) (string, error) {

func input(r io.Reader, out io.Writer, prompt string) (string, error) {
reader := bufio.NewScanner(r)
fmt.Fprintf(out, prompt+" ")
fmt.Fprintf(out, "%s ", prompt)

if !reader.Scan() {
return "", errors.New("error reading user input")
Expand Down
6 changes: 3 additions & 3 deletions pkg/control/v1/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package client
import (
"context"
"encoding/json"
"fmt"
"errors"
"sync"
"time"

Expand Down Expand Up @@ -165,7 +165,7 @@ func (c *client) Restart(ctx context.Context) error {
return err
}
if res.Status == proto.ActionStatus_V1_FAILURE {
return fmt.Errorf(res.Error)
return errors.New(res.Error)
}
return nil
}
Expand All @@ -180,7 +180,7 @@ func (c *client) Upgrade(ctx context.Context, version string, sourceURI string)
return "", err
}
if res.Status == proto.ActionStatus_V1_FAILURE {
return "", fmt.Errorf(res.Error)
return "", errors.New(res.Error)
}
return res.Version, nil
}
4 changes: 2 additions & 2 deletions pkg/control/v2/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ func (c *client) Restart(ctx context.Context) error {
return err
}
if res.Status == cproto.ActionStatus_FAILURE {
return fmt.Errorf(res.Error)
return errors.New(res.Error)
}
return nil
}
Expand All @@ -313,7 +313,7 @@ func (c *client) Upgrade(ctx context.Context, version string, sourceURI string,
return "", err
}
if res.Status == cproto.ActionStatus_FAILURE {
return "", fmt.Errorf(res.Error)
return "", errors.New(res.Error)
}
return res.Version, nil
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/testing/multipass/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"os"
"os/exec"
Expand Down Expand Up @@ -208,7 +209,7 @@ func (p *provisioner) ensureInstanceNotExist(ctx context.Context, batch common.O
p.logger.Logf(msg)
p.logger.Logf("output: %s", output.String())
p.logger.Logf("stderr: %s", stdErr.String())
return fmt.Errorf(msg)
return errors.New(msg)
}
list := struct {
List []struct {
Expand Down Expand Up @@ -248,7 +249,7 @@ func (p *provisioner) ensureInstanceNotExist(ctx context.Context, batch common.O
p.logger.Logf(msg)
p.logger.Logf("output: %s", output.String())
p.logger.Logf("stderr: %s", stdErr.String())
return fmt.Errorf(msg)
return errors.New(msg)
}

break
Expand Down

0 comments on commit f067c92

Please sign in to comment.