Skip to content

Commit

Permalink
Fix staticcheck findings (#262)
Browse files Browse the repository at this point in the history
Address some minor issues flagged by staticcheck.
None of these affect the correctness of the package.
  • Loading branch information
dsnet authored May 27, 2021
1 parent d103655 commit 248ccff
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions cmp/compare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -657,8 +657,8 @@ func comparerTests() []test {
reason: "all zero map entries are ignored (even if missing)",
}, {
label: label + "/PanicUnexportedNamed",
x: namedWithUnexported{},
y: namedWithUnexported{},
x: namedWithUnexported{unexported: "x"},
y: namedWithUnexported{unexported: "y"},
wantPanic: strconv.Quote(reflect.TypeOf(namedWithUnexported{}).PkgPath()) + ".namedWithUnexported",
reason: "panic on named struct type with unexported field",
}, {
Expand Down Expand Up @@ -1279,11 +1279,11 @@ using the AllowUnexported option.`, "\n"),
}, {
label: label + "/LargeMapKey",
x: map[*[]byte]int{func() *[]byte {
b := make([]byte, 1<<20, 1<<20)
b := make([]byte, 1<<20)
return &b
}(): 0},
y: map[*[]byte]int{func() *[]byte {
b := make([]byte, 1<<20, 1<<20)
b := make([]byte, 1<<20)
return &b
}(): 0},
reason: "printing map keys should have some verbosity limit imposed",
Expand Down
8 changes: 4 additions & 4 deletions cmp/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ func ExampleOption_equalNaNs() {
return (math.IsNaN(x) && math.IsNaN(y)) || x == y
})

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

fmt.Println(cmp.Equal(x, y, opt))
fmt.Println(cmp.Equal(y, z, opt))
Expand Down Expand Up @@ -216,7 +216,7 @@ func ExampleOption_sortedSlice() {
type otherString string

func (x otherString) Equal(y otherString) bool {
return strings.ToLower(string(x)) == strings.ToLower(string(y))
return strings.EqualFold(string(x), string(y))
}

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

0 comments on commit 248ccff

Please sign in to comment.