Skip to content

Commit

Permalink
Fixed panic message in IgnoreUnexported
Browse files Browse the repository at this point in the history
Fixed panic message more specifically.
With this fix, you can see that IgnoreUnexported only supports a struct without the user having to look at the code.
  • Loading branch information
ko30005 committed Jul 14, 2020
1 parent d669b04 commit 996994d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmp/cmpopts/ignore.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func newUnexportedFilter(typs ...interface{}) unexportedFilter {
for _, typ := range typs {
t := reflect.TypeOf(typ)
if t == nil || t.Kind() != reflect.Struct {
panic(fmt.Sprintf("invalid struct type: %T", typ))
panic(fmt.Sprintf("%T must be a non-pointer struct", typ))
}
ux.m[t] = true
}
Expand Down
4 changes: 2 additions & 2 deletions cmp/cmpopts/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1304,13 +1304,13 @@ func TestPanic(t *testing.T) {
label: "IgnoreUnexported",
fnc: IgnoreUnexported,
args: args(nil),
wantPanic: "invalid struct type",
wantPanic: "<nil> must be a non-pointer struct",
reason: "input must not be nil value",
}, {
label: "IgnoreUnexported",
fnc: IgnoreUnexported,
args: args(&Foo1{}),
wantPanic: "invalid struct type",
wantPanic: "*cmpopts.Foo1 must be a non-pointer struct",
reason: "input must be a struct type (not a pointer to a struct)",
}, {
label: "IgnoreUnexported",
Expand Down

0 comments on commit 996994d

Please sign in to comment.