From 248ccfffa4b8906ebc7f9ab720fe5b6012bb7745 Mon Sep 17 00:00:00 2001 From: Joe Tsai Date: Thu, 27 May 2021 09:45:01 -0700 Subject: [PATCH] Fix staticcheck findings (#262) Address some minor issues flagged by staticcheck. None of these affect the correctness of the package. --- cmp/compare_test.go | 8 ++++---- cmp/example_test.go | 8 ++++---- 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