Skip to content

Commit

Permalink
fix golangci-lint
Browse files Browse the repository at this point in the history
  • Loading branch information
phbnf committed Feb 13, 2025
1 parent 8bf3fae commit 1006b3f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions monitoring/testonly/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func TestCounter(t *testing.T, factory monitoring.MetricFactory) {
// Use a different set of label values
// Metrics with different valued label values, are distinct
// This test is only applicable when a Metric has labels
if test.labelVals != nil && len(test.labelVals) >= 1 {
if len(test.labelVals) >= 1 {
altLabels := make([]string, len(test.labelVals))
copy(altLabels, test.labelVals)
altLabels[0] = "alt-val1"
Expand Down Expand Up @@ -151,7 +151,7 @@ func TestGauge(t *testing.T, factory monitoring.MetricFactory) {
// Use a different set of label values
// Metrics with different valued label values, are distinct
// This test is only applicable when a Metric has labels
if test.labelVals != nil && len(test.labelVals) >= 1 {
if len(test.labelVals) >= 1 {
altLabels := make([]string, len(test.labelVals))
copy(altLabels, test.labelVals)
altLabels[0] = "alt-val1"
Expand Down Expand Up @@ -223,7 +223,7 @@ func TestHistogram(t *testing.T, factory monitoring.MetricFactory) {
// Use a different set of label values
// Metrics with different valued label values, are distinct
// This test is only applicable when a Metric has labels
if test.labelVals != nil && len(test.labelVals) >= 1 {
if len(test.labelVals) >= 1 {
altLabels := make([]string, len(test.labelVals))
copy(altLabels, test.labelVals)
altLabels[0] = "alt-val1"
Expand Down
3 changes: 2 additions & 1 deletion server/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import (
// (such as canonical SQL errors), else err is returned unmodified.
func WrapError(err error) error {
if err == sql.ErrNoRows {
return status.Errorf(codes.NotFound, err.Error())
e := err.Error()
return status.Errorf(codes.NotFound, e)

Check failure on line 29 in server/errors/errors.go

View workflow job for this annotation

GitHub Actions / lint

printf: non-constant format string in call to google.golang.org/grpc/status.Errorf (govet)
}

return err
Expand Down
3 changes: 2 additions & 1 deletion server/errors/errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
func TestWrapError(t *testing.T) {
grpcErr := status.Errorf(codes.NotFound, "not found err")
err := errors.New("generic error")
noRowsErr := sql.ErrNoRows.Error()

tests := []struct {
err error
Expand All @@ -42,7 +43,7 @@ func TestWrapError(t *testing.T) {
},
{
err: sql.ErrNoRows,
wantErr: status.Errorf(codes.NotFound, sql.ErrNoRows.Error()),
wantErr: status.Errorf(codes.NotFound, noRowsErr),

Check failure on line 46 in server/errors/errors_test.go

View workflow job for this annotation

GitHub Actions / lint

printf: non-constant format string in call to google.golang.org/grpc/status.Errorf (govet)
},
}
for _, test := range tests {
Expand Down

0 comments on commit 1006b3f

Please sign in to comment.