cmd/protoc-gen-go: fix Reset method

The MessageInfo cache, once set, must not be cleared, otherwise
there exists a *messageState value where the MessageInfo value is nil.
Fix the generation of the Reset method to avoid clearing this value.

Change-Id: Ic84ca8b2640a43e967c36993da1ccd3f2b7096c4
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/201478
Reviewed-by: Damien Neil <dneil@google.com>
diff --git a/internal/testprotos/test3/test.pb.go b/internal/testprotos/test3/test.pb.go
index cd75988..145cf43 100644
--- a/internal/testprotos/test3/test.pb.go
+++ b/internal/testprotos/test3/test.pb.go
@@ -197,6 +197,11 @@
 
 func (x *TestAllTypes) Reset() {
 	*x = TestAllTypes{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_test3_test_proto_msgTypes[0]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
 }
 
 func (x *TestAllTypes) String() string {
@@ -774,6 +779,11 @@
 
 func (x *ForeignMessage) Reset() {
 	*x = ForeignMessage{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_test3_test_proto_msgTypes[1]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
 }
 
 func (x *ForeignMessage) String() string {
@@ -824,6 +834,11 @@
 
 func (x *TestAllTypes_NestedMessage) Reset() {
 	*x = TestAllTypes_NestedMessage{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_test3_test_proto_msgTypes[2]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
 }
 
 func (x *TestAllTypes_NestedMessage) String() string {
diff --git a/internal/testprotos/test3/test_import.pb.go b/internal/testprotos/test3/test_import.pb.go
index 878330d..78ce012 100644
--- a/internal/testprotos/test3/test_import.pb.go
+++ b/internal/testprotos/test3/test_import.pb.go
@@ -65,6 +65,11 @@
 
 func (x *ImportMessage) Reset() {
 	*x = ImportMessage{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_test3_test_import_proto_msgTypes[0]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
 }
 
 func (x *ImportMessage) String() string {