Skip to content

Commit 07f22fc

Browse files
dolmensbinet
authored andcommitted
sliceop: use errors.New for constant errors
use errors.New instead of fmt.Errorf when the message is a constant string.
1 parent 40700b8 commit 07f22fc

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

sliceop/f64s/f64s_test.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package f64s
66

77
import (
8+
"errors"
89
"fmt"
910
"math/rand"
1011
"reflect"
@@ -35,9 +36,9 @@ func TestMap(t *testing.T) {
3536

3637
func TestTake(t *testing.T) {
3738
var (
38-
errLength = fmt.Errorf("sliceop: length mismatch")
39-
errSortedIndices = fmt.Errorf("sliceop: indices not sorted")
40-
errDuplicateIndices = fmt.Errorf("sliceop: duplicate indices")
39+
errLength = errors.New("sliceop: length mismatch")
40+
errSortedIndices = errors.New("sliceop: indices not sorted")
41+
errDuplicateIndices = errors.New("sliceop: duplicate indices")
4142
)
4243

4344
for _, tc := range []struct {

sliceop/sliceop.go

+4-6
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@
88
// slices package.
99
package sliceop // import "go-hep.org/x/hep/sliceop"
1010

11-
import (
12-
"fmt"
13-
)
11+
import "errors"
1412

1513
var (
16-
errLength = fmt.Errorf("sliceop: length mismatch")
17-
errSortedIndices = fmt.Errorf("sliceop: indices not sorted")
18-
errDuplicateIndices = fmt.Errorf("sliceop: duplicate indices")
14+
errLength = errors.New("sliceop: length mismatch")
15+
errSortedIndices = errors.New("sliceop: indices not sorted")
16+
errDuplicateIndices = errors.New("sliceop: duplicate indices")
1917
)
2018

2119
// Filter creates a slice with all the elements x_i of src for which f(x_i) is true.

0 commit comments

Comments
 (0)