aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Tsai <joetsai@digital-static.net>2021-05-27 09:45:01 -0700
committerGitHub <noreply@github.com>2021-05-27 09:45:01 -0700
commit248ccfffa4b8906ebc7f9ab720fe5b6012bb7745 (patch)
treea907336285c284211c2454d24f50da064ebc0177
parentd103655696d8ae43c4125ee61454dbf03d8e8324 (diff)
downloadgo-cmp-248ccfffa4b8906ebc7f9ab720fe5b6012bb7745.tar.gz
Fix staticcheck findings (#262)
Address some minor issues flagged by staticcheck. None of these affect the correctness of the package.
-rw-r--r--cmp/compare_test.go8
-rw-r--r--cmp/example_test.go8
2 files changed, 8 insertions, 8 deletions
diff --git a/cmp/compare_test.go b/cmp/compare_test.go
index 649c917..dc0bfe0 100644
--- a/cmp/compare_test.go
+++ b/cmp/compare_test.go
@@ -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",
}, {
@@ -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",
diff --git a/cmp/example_test.go b/cmp/example_test.go
index d165383..e1f4338 100644
--- a/cmp/example_test.go
+++ b/cmp/example_test.go
@@ -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))
@@ -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