Skip to content

Commit 248ccff

Browse files
authored
Fix staticcheck findings (#262)
Address some minor issues flagged by staticcheck. None of these affect the correctness of the package.
1 parent d103655 commit 248ccff

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

cmp/compare_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -657,8 +657,8 @@ func comparerTests() []test {
657657
reason: "all zero map entries are ignored (even if missing)",
658658
}, {
659659
label: label + "/PanicUnexportedNamed",
660-
x: namedWithUnexported{},
661-
y: namedWithUnexported{},
660+
x: namedWithUnexported{unexported: "x"},
661+
y: namedWithUnexported{unexported: "y"},
662662
wantPanic: strconv.Quote(reflect.TypeOf(namedWithUnexported{}).PkgPath()) + ".namedWithUnexported",
663663
reason: "panic on named struct type with unexported field",
664664
}, {
@@ -1279,11 +1279,11 @@ using the AllowUnexported option.`, "\n"),
12791279
}, {
12801280
label: label + "/LargeMapKey",
12811281
x: map[*[]byte]int{func() *[]byte {
1282-
b := make([]byte, 1<<20, 1<<20)
1282+
b := make([]byte, 1<<20)
12831283
return &b
12841284
}(): 0},
12851285
y: map[*[]byte]int{func() *[]byte {
1286-
b := make([]byte, 1<<20, 1<<20)
1286+
b := make([]byte, 1<<20)
12871287
return &b
12881288
}(): 0},
12891289
reason: "printing map keys should have some verbosity limit imposed",

cmp/example_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ func ExampleOption_equalNaNs() {
9898
return (math.IsNaN(x) && math.IsNaN(y)) || x == y
9999
})
100100

101-
x := []float64{1.0, math.NaN(), math.E, -0.0, +0.0}
102-
y := []float64{1.0, math.NaN(), math.E, -0.0, +0.0}
103-
z := []float64{1.0, math.NaN(), math.Pi, -0.0, +0.0} // Pi constant instead of E
101+
x := []float64{1.0, math.NaN(), math.E, 0.0}
102+
y := []float64{1.0, math.NaN(), math.E, 0.0}
103+
z := []float64{1.0, math.NaN(), math.Pi, 0.0} // Pi constant instead of E
104104

105105
fmt.Println(cmp.Equal(x, y, opt))
106106
fmt.Println(cmp.Equal(y, z, opt))
@@ -216,7 +216,7 @@ func ExampleOption_sortedSlice() {
216216
type otherString string
217217

218218
func (x otherString) Equal(y otherString) bool {
219-
return strings.ToLower(string(x)) == strings.ToLower(string(y))
219+
return strings.EqualFold(string(x), string(y))
220220
}
221221

222222
// If the Equal method defined on a type is not suitable, the type can be

0 commit comments

Comments
 (0)