Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x](backport #5651) fix go vet errors with Go 1.24 #5684

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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