Skip to content

Commit 1006b3f

Browse files
committed
fix golangci-lint
1 parent 8bf3fae commit 1006b3f

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

monitoring/testonly/metrics.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func TestCounter(t *testing.T, factory monitoring.MetricFactory) {
7171
// Use a different set of label values
7272
// Metrics with different valued label values, are distinct
7373
// This test is only applicable when a Metric has labels
74-
if test.labelVals != nil && len(test.labelVals) >= 1 {
74+
if len(test.labelVals) >= 1 {
7575
altLabels := make([]string, len(test.labelVals))
7676
copy(altLabels, test.labelVals)
7777
altLabels[0] = "alt-val1"
@@ -151,7 +151,7 @@ func TestGauge(t *testing.T, factory monitoring.MetricFactory) {
151151
// Use a different set of label values
152152
// Metrics with different valued label values, are distinct
153153
// This test is only applicable when a Metric has labels
154-
if test.labelVals != nil && len(test.labelVals) >= 1 {
154+
if len(test.labelVals) >= 1 {
155155
altLabels := make([]string, len(test.labelVals))
156156
copy(altLabels, test.labelVals)
157157
altLabels[0] = "alt-val1"
@@ -223,7 +223,7 @@ func TestHistogram(t *testing.T, factory monitoring.MetricFactory) {
223223
// Use a different set of label values
224224
// Metrics with different valued label values, are distinct
225225
// This test is only applicable when a Metric has labels
226-
if test.labelVals != nil && len(test.labelVals) >= 1 {
226+
if len(test.labelVals) >= 1 {
227227
altLabels := make([]string, len(test.labelVals))
228228
copy(altLabels, test.labelVals)
229229
altLabels[0] = "alt-val1"

server/errors/errors.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ import (
2525
// (such as canonical SQL errors), else err is returned unmodified.
2626
func WrapError(err error) error {
2727
if err == sql.ErrNoRows {
28-
return status.Errorf(codes.NotFound, err.Error())
28+
e := err.Error()
29+
return status.Errorf(codes.NotFound, e)
2930
}
3031

3132
return err

server/errors/errors_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
func TestWrapError(t *testing.T) {
2828
grpcErr := status.Errorf(codes.NotFound, "not found err")
2929
err := errors.New("generic error")
30+
noRowsErr := sql.ErrNoRows.Error()
3031

3132
tests := []struct {
3233
err error
@@ -42,7 +43,7 @@ func TestWrapError(t *testing.T) {
4243
},
4344
{
4445
err: sql.ErrNoRows,
45-
wantErr: status.Errorf(codes.NotFound, sql.ErrNoRows.Error()),
46+
wantErr: status.Errorf(codes.NotFound, noRowsErr),
4647
},
4748
}
4849
for _, test := range tests {

0 commit comments

Comments
 (0)