diff --git a/gomock/string.go b/gomock/string.go index ec4ca7e4..1f6ddbca 100644 --- a/gomock/string.go +++ b/gomock/string.go @@ -12,6 +12,10 @@ func getString(x any) string { if isGeneratedMock(x) { return fmt.Sprintf("%T", x) } + typ := reflect.ValueOf(x) + if typ.Kind() == reflect.Ptr && typ.IsNil() { + return "nil" + } if s, ok := x.(fmt.Stringer); ok { return s.String() }