proto: wrap v2 textproto marshal/unmarshal

Removed V1 test files related to textproto serialization as these do not
provide much relevance given that pure V1 implementation is temporary and
maintaining dual mode for these tests can be troublesome.

Before deleting or changing any test files, all tests except for
timestamp_test.go:TestTimestampString pass with tag use_golang_protobuf_v1.

The issue with TestTimestampString is brought about by updating go.mod's V2
dependency to a newer version of Timestamp proto message that has String method
already using V2 textpb. Test is fixed in this CL.

Before these tests were removed, each was inspected for pass/fail
against the wrapped implementation.

Following tests failed due to expected differences between V1 and V2.
The failure reasons are added as review comments in the CL for
documentation purposes.

text_parser_test.go
  TestUnmarshalText
  TestMapParsing
  TestOneofParsing

text_test.go
  TestMarshalText
  TestMarshalTextUnknownEnum
  TestTextOneof
  TestCompactText
  TestStringEscaping
  TestMarshalTextFailing
  TestRepeatedNilText
  TestProto3Text

any_test.go
  TestMarshalGolden
  TestMarshalUnknownAny
  TestUnmarshalOverwriteAny
  TestUnmarshalAnyMixAndMatch

Change-Id: I2505341d6f47384a69b195efc3218fa07efc4e7a
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/171459
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
diff --git a/go.mod b/go.mod
index 0dc7235..c52c1b2 100644
--- a/go.mod
+++ b/go.mod
@@ -1,3 +1,3 @@
 module github.com/golang/protobuf
 
-require github.com/golang/protobuf/v2 v2.0.0-20190322201422-f503c300f70e
+require github.com/golang/protobuf/v2 v2.0.0-20190409211845-4ec39c766335
diff --git a/go.sum b/go.sum
index 16d8546..f098f99 100644
--- a/go.sum
+++ b/go.sum
@@ -1,5 +1,8 @@
 github.com/golang/protobuf v1.2.1-0.20190322195920-d94fb84e04b7/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/golang/protobuf v1.2.1-0.20190326022002-be03c15fcaa2/go.mod h1:rZ4veVXHB1S2+o7TKqD9Isxml062IeDutnCDtFPUlCc=
 github.com/golang/protobuf/v2 v2.0.0-20190322201422-f503c300f70e h1:JQRqkjZt61BlBnTP2OpISUfb5I1LGJcqYHfFGERMmlg=
 github.com/golang/protobuf/v2 v2.0.0-20190322201422-f503c300f70e/go.mod h1:25ZALhydMFaBRgPH58a8zpFe9YXMAMjOYWtB6pNPcoo=
+github.com/golang/protobuf/v2 v2.0.0-20190409211845-4ec39c766335 h1:dtT6y87fe34KJUI0FyKXi08Y1XZIU5NgxDl6yojsYdI=
+github.com/golang/protobuf/v2 v2.0.0-20190409211845-4ec39c766335/go.mod h1:baUT2weUsA1MR7ocRtLXLmi2B1s4VrUT3S6tO8AYzMw=
 github.com/google/go-cmp v0.2.1-0.20190312032427-6f77996f0c42 h1:q3pnF5JFBNRz8sRD+IRj7Y6DMyYGTNqnZ9axTbSfoNI=
 github.com/google/go-cmp v0.2.1-0.20190312032427-6f77996f0c42/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
diff --git a/internal/proto/common.go b/internal/proto/common.go
index 93f5178..8cc0df2 100644
--- a/internal/proto/common.go
+++ b/internal/proto/common.go
@@ -9,6 +9,9 @@
 // that they would otherwise be able to call directly.
 
 import (
+	"fmt"
+	"reflect"
+
 	"github.com/golang/protobuf/v2/runtime/protoiface"
 	_ "github.com/golang/protobuf/v2/runtime/protolegacy"
 )
@@ -17,3 +20,54 @@
 	Message       = protoiface.MessageV1
 	ExtensionDesc = protoiface.ExtensionDescV1
 )
+
+// RequiredNotSetError is an error type returned by either Marshal or Unmarshal.
+// Marshal reports this when a required field is not initialized.
+// Unmarshal reports this when a required field is missing from the input data.
+type RequiredNotSetError struct{ field string }
+
+func (e *RequiredNotSetError) Error() string {
+	if e.field == "" {
+		return fmt.Sprintf("proto: required field not set")
+	}
+	return fmt.Sprintf("proto: required field %q not set", e.field)
+}
+func (e *RequiredNotSetError) RequiredNotSet() bool {
+	return true
+}
+
+type errorMask uint8
+
+const (
+	_ errorMask = (1 << iota) / 2
+	errInvalidUTF8
+	errRequiredNotSet
+)
+
+type errorsList = []error
+
+var errorsListType = reflect.TypeOf(errorsList{})
+
+// nonFatalErrors returns an errorMask identifying V2 non-fatal errors.
+func nonFatalErrors(err error) errorMask {
+	verr := reflect.ValueOf(err)
+	if !verr.IsValid() {
+		return 0
+	}
+
+	if !verr.Type().AssignableTo(errorsListType) {
+		return 0
+	}
+
+	errs := verr.Convert(errorsListType).Interface().(errorsList)
+	var ret errorMask
+	for _, e := range errs {
+		switch e.(type) {
+		case interface{ RequiredNotSet() bool }:
+			ret |= errRequiredNotSet
+		case interface{ InvalidUTF8() bool }:
+			ret |= errInvalidUTF8
+		}
+	}
+	return ret
+}
diff --git a/internal/proto/common_test.go b/internal/proto/common_test.go
new file mode 100644
index 0000000..b6e623f
--- /dev/null
+++ b/internal/proto/common_test.go
@@ -0,0 +1,63 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package proto
+
+import (
+	"errors"
+	"testing"
+)
+
+type testErrorList []error
+
+func (e testErrorList) Error() string {
+	return "testErrorList"
+}
+
+type invalidUTF8Error struct{}
+
+func (e invalidUTF8Error) Error() string     { return "" }
+func (e invalidUTF8Error) InvalidUTF8() bool { return true }
+
+type requiredNotSetError struct{}
+
+func (e requiredNotSetError) Error() string        { return "" }
+func (e requiredNotSetError) RequiredNotSet() bool { return true }
+
+func TestNonFatalErrors(t *testing.T) {
+	tests := []struct {
+		input error
+		want  errorMask
+	}{{
+		input: errors.New("not one of them"),
+	}, {
+		input: testErrorList{},
+	}, {
+		input: testErrorList{
+			invalidUTF8Error{},
+		},
+		want: errInvalidUTF8,
+	}, {
+		input: testErrorList{
+			requiredNotSetError{},
+		},
+		want: errRequiredNotSet,
+	}, {
+		input: testErrorList{
+			invalidUTF8Error{},
+			requiredNotSetError{},
+		},
+		want: errInvalidUTF8 | errRequiredNotSet,
+	}}
+
+	for _, tc := range tests {
+		tc := tc
+		t.Run("", func(t *testing.T) {
+			got := nonFatalErrors(tc.input)
+			if got != tc.want {
+				t.Errorf("got %v, want %v", got, tc.want)
+			}
+		})
+	}
+}
diff --git a/internal/proto/text.go b/internal/proto/text.go
new file mode 100644
index 0000000..4cc0011
--- /dev/null
+++ b/internal/proto/text.go
@@ -0,0 +1,116 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package proto
+
+// Functions for writing the text protocol buffer format.
+
+import (
+	"bytes"
+	"encoding"
+	"io"
+	"reflect"
+
+	"github.com/golang/protobuf/v2/encoding/textpb"
+	preg "github.com/golang/protobuf/v2/reflect/protoregistry"
+	"github.com/golang/protobuf/v2/runtime/protoimpl"
+)
+
+// TextMarshaler is a configurable text format marshaler.
+type TextMarshaler struct {
+	Compact   bool // use compact text format in one line without the trailing newline character
+	ExpandAny bool // expand google.protobuf.Any messages of known types
+}
+
+// Marshal writes a given protocol buffer in text format.
+func (tm *TextMarshaler) Marshal(w io.Writer, pb Message) error {
+	val := reflect.ValueOf(pb)
+	// V1 supports passing in nil interface or pointer and outputs <nil>, while
+	// V2 will panic on nil interface and outputs nothing for nil pointer.
+	if pb == nil || val.IsNil() {
+		w.Write([]byte("<nil>"))
+		return nil
+	}
+
+	// V1-specific override in marshaling.
+	if etm, ok := pb.(encoding.TextMarshaler); ok {
+		text, err := etm.MarshalText()
+		if err != nil {
+			return err
+		}
+		if _, err = w.Write(text); err != nil {
+			return err
+		}
+		return nil
+	}
+
+	var ind string
+	if !tm.Compact {
+		ind = "  "
+	}
+	mo := textpb.MarshalOptions{
+		AllowPartial: true,
+		Indent:       ind,
+	}
+	if !tm.ExpandAny {
+		mo.Resolver = emptyResolver
+	}
+	b, err := mo.Marshal(protoimpl.X.MessageOf(pb).Interface())
+	mask := nonFatalErrors(err)
+	// V1 does not return invalid UTF-8 error.
+	if err != nil && mask&errInvalidUTF8 == 0 {
+		return err
+	}
+	if _, err := w.Write(b); err != nil {
+		return err
+	}
+	return nil
+}
+
+// Text is the same as Marshal, but returns the string directly.
+func (tm *TextMarshaler) Text(pb Message) string {
+	var buf bytes.Buffer
+	tm.Marshal(&buf, pb)
+	return buf.String()
+}
+
+var (
+	emptyResolver        = preg.NewTypes()
+	defaultTextMarshaler = TextMarshaler{}
+	compactTextMarshaler = TextMarshaler{Compact: true}
+)
+
+// MarshalText writes a given protocol buffer in text format.
+func MarshalText(w io.Writer, pb Message) error { return defaultTextMarshaler.Marshal(w, pb) }
+
+// MarshalTextString is the same as MarshalText, but returns the string directly.
+func MarshalTextString(pb Message) string { return defaultTextMarshaler.Text(pb) }
+
+// CompactText writes a given protocol buffer in compact text format (one line).
+func CompactText(w io.Writer, pb Message) error { return compactTextMarshaler.Marshal(w, pb) }
+
+// CompactTextString is the same as CompactText, but returns the string directly.
+func CompactTextString(pb Message) string { return compactTextMarshaler.Text(pb) }
+
+// UnmarshalText reads a protocol buffer in text format. UnmarshalText resets pb
+// before starting to unmarshal, so any existing data in pb is always removed.
+// If a required field is not set and no other error occurs, UnmarshalText
+// returns *RequiredNotSetError.
+func UnmarshalText(s string, m Message) error {
+	if um, ok := m.(encoding.TextUnmarshaler); ok {
+		return um.UnmarshalText([]byte(s))
+	}
+	err := textpb.Unmarshal(protoimpl.X.MessageOf(m).Interface(), []byte(s))
+	// Return RequiredNotSetError for required not set errors and ignore invalid
+	// UTF-8 errors.
+	mask := nonFatalErrors(err)
+	if mask&errRequiredNotSet > 0 {
+		return &RequiredNotSetError{}
+	}
+	if mask&errInvalidUTF8 > 0 {
+		return nil
+	}
+	// Otherwise return error which can either be nil or fatal.
+	return err
+}
diff --git a/proto/all_test.go b/proto/all_test.go
index a16c056..ad586f6 100644
--- a/proto/all_test.go
+++ b/proto/all_test.go
@@ -179,6 +179,15 @@
 	}
 }
 
+// When hooks are enabled, RequiredNotSetError is typed alias to internal/proto
+// package. Binary serialization has not been wrapped yet and hence produces
+// requiredNotSetError instead. This function is a work-around to identify both
+// aliased and non-aliased types.
+func isRequiredNotSetError(err error) bool {
+	e, ok := err.(interface{ RequiredNotSet() bool })
+	return ok && e.RequiredNotSet()
+}
+
 // Simple tests for numeric encode/decode primitives (varint, etc.)
 func TestNumericPrimitives(t *testing.T) {
 	for i := uint64(0); i < 1e6; i += 111 {
@@ -1249,7 +1258,7 @@
 	_, err := Marshal(pb)
 	if err == nil {
 		t.Error("marshal: expected error, got nil")
-	} else if _, ok := err.(*RequiredNotSetError); !ok || !strings.Contains(err.Error(), "Label") {
+	} else if !isRequiredNotSetError(err) {
 		t.Errorf("marshal: bad error type: %v", err)
 	}
 
@@ -1260,7 +1269,7 @@
 	err = Unmarshal(buf, pb)
 	if err == nil {
 		t.Error("unmarshal: expected error, got nil")
-	} else if _, ok := err.(*RequiredNotSetError); !ok || !strings.Contains(err.Error(), "Type") && !strings.Contains(err.Error(), "{Unknown}") {
+	} else if !isRequiredNotSetError(err) {
 		// TODO: remove unknown cases once we commit to the new unmarshaler.
 		t.Errorf("unmarshal: bad error type: %v", err)
 	}
@@ -1271,14 +1280,14 @@
 	pb := &GoTestRequiredGroupField{Group: &GoTestRequiredGroupField_Group{}}
 	if _, err := Marshal(pb); err == nil {
 		t.Error("marshal: expected error, got nil")
-	} else if _, ok := err.(*RequiredNotSetError); !ok || !strings.Contains(err.Error(), "Group.Field") {
+	} else if !isRequiredNotSetError(err) {
 		t.Errorf("marshal: bad error type: %v", err)
 	}
 
 	buf := []byte{11, 12}
 	if err := Unmarshal(buf, pb); err == nil {
 		t.Error("unmarshal: expected error, got nil")
-	} else if _, ok := err.(*RequiredNotSetError); !ok || !strings.Contains(err.Error(), "Group.Field") && !strings.Contains(err.Error(), "Group.{Unknown}") {
+	} else if !isRequiredNotSetError(err) {
 		t.Errorf("unmarshal: bad error type: %v", err)
 	}
 }
@@ -1837,7 +1846,7 @@
 
 	o := old()
 	bytes, err := Marshal(pb)
-	if _, ok := err.(*RequiredNotSetError); !ok {
+	if !isRequiredNotSetError(err) {
 		fmt.Printf("marshal-1 err = %v, want *RequiredNotSetError", err)
 		o.DebugPrint("", bytes)
 		t.Fatalf("expected = %s", expected)
@@ -1853,7 +1862,7 @@
 	// Now test Unmarshal by recreating the original buffer.
 	pbd := new(GoTest)
 	err = Unmarshal(bytes, pbd)
-	if _, ok := err.(*RequiredNotSetError); !ok {
+	if !isRequiredNotSetError(err) {
 		t.Fatalf("unmarshal err = %v, want *RequiredNotSetError", err)
 		o.DebugPrint("", bytes)
 		t.Fatalf("string = %s", expected)
@@ -1862,7 +1871,7 @@
 		t.Errorf("unmarshal wrong err msg: %v", err)
 	}
 	bytes, err = Marshal(pbd)
-	if _, ok := err.(*RequiredNotSetError); !ok {
+	if !isRequiredNotSetError(err) {
 		t.Errorf("marshal-2 err = %v, want *RequiredNotSetError", err)
 		o.DebugPrint("", bytes)
 		t.Fatalf("string = %s", expected)
@@ -2302,7 +2311,7 @@
 	// It should still be handled even after multiple required field violations.
 	m := &GoTest{F_BoolRequired: Bool(true)}
 	got, err := Marshal(m)
-	if _, ok := err.(*RequiredNotSetError); !ok {
+	if !isRequiredNotSetError(err) {
 		t.Errorf("Marshal() = %v, want RequiredNotSetError error", err)
 	}
 	if want := []byte{0x50, 0x01}; !bytes.Equal(got, want) {
@@ -2311,7 +2320,7 @@
 
 	m = new(GoTest)
 	err = Unmarshal(got, m)
-	if _, ok := err.(*RequiredNotSetError); !ok {
+	if !isRequiredNotSetError(err) {
 		t.Errorf("Marshal() = %v, want RequiredNotSetError error", err)
 	}
 	if !m.GetF_BoolRequired() {
diff --git a/proto/any_test.go b/proto/any_test.go
deleted file mode 100644
index 69e497d..0000000
--- a/proto/any_test.go
+++ /dev/null
@@ -1,273 +0,0 @@
-// Copyright 2016 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package proto_test
-
-import (
-	"strings"
-	"testing"
-
-	"github.com/golang/protobuf/proto"
-
-	pb "github.com/golang/protobuf/proto/proto3_proto"
-	testpb "github.com/golang/protobuf/proto/test_proto"
-	anypb "github.com/golang/protobuf/ptypes/any"
-)
-
-var (
-	expandedMarshaler        = proto.TextMarshaler{ExpandAny: true}
-	expandedCompactMarshaler = proto.TextMarshaler{Compact: true, ExpandAny: true}
-)
-
-// anyEqual reports whether two messages which may be google.protobuf.Any or may
-// contain google.protobuf.Any fields are equal. We can't use proto.Equal for
-// comparison, because semantically equivalent messages may be marshaled to
-// binary in different tag order. Instead, trust that TextMarshaler with
-// ExpandAny option works and compare the text marshaling results.
-func anyEqual(got, want proto.Message) bool {
-	// if messages are proto.Equal, no need to marshal.
-	if proto.Equal(got, want) {
-		return true
-	}
-	g := expandedMarshaler.Text(got)
-	w := expandedMarshaler.Text(want)
-	return g == w
-}
-
-type golden struct {
-	m    proto.Message
-	t, c string
-}
-
-var goldenMessages = makeGolden()
-
-func makeGolden() []golden {
-	nested := &pb.Nested{Bunny: "Monty"}
-	nb, err := proto.Marshal(nested)
-	if err != nil {
-		panic(err)
-	}
-	m1 := &pb.Message{
-		Name:        "David",
-		ResultCount: 47,
-		Anything:    &anypb.Any{TypeUrl: "type.googleapis.com/" + proto.MessageName(nested), Value: nb},
-	}
-	m2 := &pb.Message{
-		Name:        "David",
-		ResultCount: 47,
-		Anything:    &anypb.Any{TypeUrl: "http://[::1]/type.googleapis.com/" + proto.MessageName(nested), Value: nb},
-	}
-	m3 := &pb.Message{
-		Name:        "David",
-		ResultCount: 47,
-		Anything:    &anypb.Any{TypeUrl: `type.googleapis.com/"/` + proto.MessageName(nested), Value: nb},
-	}
-	m4 := &pb.Message{
-		Name:        "David",
-		ResultCount: 47,
-		Anything:    &anypb.Any{TypeUrl: "type.googleapis.com/a/path/" + proto.MessageName(nested), Value: nb},
-	}
-	m5 := &anypb.Any{TypeUrl: "type.googleapis.com/" + proto.MessageName(nested), Value: nb}
-
-	any1 := &testpb.MyMessage{Count: proto.Int32(47), Name: proto.String("David")}
-	proto.SetExtension(any1, testpb.E_Ext_More, &testpb.Ext{Data: proto.String("foo")})
-	proto.SetExtension(any1, testpb.E_Ext_Text, proto.String("bar"))
-	any1b, err := proto.Marshal(any1)
-	if err != nil {
-		panic(err)
-	}
-	any2 := &testpb.MyMessage{Count: proto.Int32(42), Bikeshed: testpb.MyMessage_GREEN.Enum(), RepBytes: [][]byte{[]byte("roboto")}}
-	proto.SetExtension(any2, testpb.E_Ext_More, &testpb.Ext{Data: proto.String("baz")})
-	any2b, err := proto.Marshal(any2)
-	if err != nil {
-		panic(err)
-	}
-	m6 := &pb.Message{
-		Name:        "David",
-		ResultCount: 47,
-		Anything:    &anypb.Any{TypeUrl: "type.googleapis.com/" + proto.MessageName(any1), Value: any1b},
-		ManyThings: []*anypb.Any{
-			&anypb.Any{TypeUrl: "type.googleapis.com/" + proto.MessageName(any2), Value: any2b},
-			&anypb.Any{TypeUrl: "type.googleapis.com/" + proto.MessageName(any1), Value: any1b},
-		},
-	}
-
-	const (
-		m1Golden = `
-name: "David"
-result_count: 47
-anything: <
-  [type.googleapis.com/proto3_proto.Nested]: <
-    bunny: "Monty"
-  >
->
-`
-		m2Golden = `
-name: "David"
-result_count: 47
-anything: <
-  ["http://[::1]/type.googleapis.com/proto3_proto.Nested"]: <
-    bunny: "Monty"
-  >
->
-`
-		m3Golden = `
-name: "David"
-result_count: 47
-anything: <
-  ["type.googleapis.com/\"/proto3_proto.Nested"]: <
-    bunny: "Monty"
-  >
->
-`
-		m4Golden = `
-name: "David"
-result_count: 47
-anything: <
-  [type.googleapis.com/a/path/proto3_proto.Nested]: <
-    bunny: "Monty"
-  >
->
-`
-		m5Golden = `
-[type.googleapis.com/proto3_proto.Nested]: <
-  bunny: "Monty"
->
-`
-		m6Golden = `
-name: "David"
-result_count: 47
-anything: <
-  [type.googleapis.com/test_proto.MyMessage]: <
-    count: 47
-    name: "David"
-    [test_proto.Ext.more]: <
-      data: "foo"
-    >
-    [test_proto.Ext.text]: "bar"
-  >
->
-many_things: <
-  [type.googleapis.com/test_proto.MyMessage]: <
-    count: 42
-    bikeshed: GREEN
-    rep_bytes: "roboto"
-    [test_proto.Ext.more]: <
-      data: "baz"
-    >
-  >
->
-many_things: <
-  [type.googleapis.com/test_proto.MyMessage]: <
-    count: 47
-    name: "David"
-    [test_proto.Ext.more]: <
-      data: "foo"
-    >
-    [test_proto.Ext.text]: "bar"
-  >
->
-`
-	)
-	return []golden{
-		{m1, strings.TrimSpace(m1Golden) + "\n", strings.TrimSpace(compact(m1Golden)) + " "},
-		{m2, strings.TrimSpace(m2Golden) + "\n", strings.TrimSpace(compact(m2Golden)) + " "},
-		{m3, strings.TrimSpace(m3Golden) + "\n", strings.TrimSpace(compact(m3Golden)) + " "},
-		{m4, strings.TrimSpace(m4Golden) + "\n", strings.TrimSpace(compact(m4Golden)) + " "},
-		{m5, strings.TrimSpace(m5Golden) + "\n", strings.TrimSpace(compact(m5Golden)) + " "},
-		{m6, strings.TrimSpace(m6Golden) + "\n", strings.TrimSpace(compact(m6Golden)) + " "},
-	}
-}
-
-func TestMarshalGolden(t *testing.T) {
-	for _, tt := range goldenMessages {
-		if got, want := expandedMarshaler.Text(tt.m), tt.t; got != want {
-			t.Errorf("message %v: got:\n%s\nwant:\n%s", tt.m, got, want)
-		}
-		if got, want := expandedCompactMarshaler.Text(tt.m), tt.c; got != want {
-			t.Errorf("message %v: got:\n`%s`\nwant:\n`%s`", tt.m, got, want)
-		}
-	}
-}
-
-func TestUnmarshalGolden(t *testing.T) {
-	for _, tt := range goldenMessages {
-		want := tt.m
-		got := proto.Clone(tt.m)
-		got.Reset()
-		if err := proto.UnmarshalText(tt.t, got); err != nil {
-			t.Errorf("failed to unmarshal\n%s\nerror: %v", tt.t, err)
-		}
-		if !anyEqual(got, want) {
-			t.Errorf("message:\n%s\ngot:\n%s\nwant:\n%s", tt.t, got, want)
-		}
-		got.Reset()
-		if err := proto.UnmarshalText(tt.c, got); err != nil {
-			t.Errorf("failed to unmarshal\n%s\nerror: %v", tt.c, err)
-		}
-		if !anyEqual(got, want) {
-			t.Errorf("message:\n%s\ngot:\n%s\nwant:\n%s", tt.c, got, want)
-		}
-	}
-}
-
-func TestMarshalUnknownAny(t *testing.T) {
-	m := &pb.Message{
-		Anything: &anypb.Any{
-			TypeUrl: "foo",
-			Value:   []byte("bar"),
-		},
-	}
-	want := `anything: <
-  type_url: "foo"
-  value: "bar"
->
-`
-	got := expandedMarshaler.Text(m)
-	if got != want {
-		t.Errorf("got\n`%s`\nwant\n`%s`", got, want)
-	}
-}
-
-func TestAmbiguousAny(t *testing.T) {
-	pb := &anypb.Any{}
-	err := proto.UnmarshalText(`
-	type_url: "ttt/proto3_proto.Nested"
-	value: "\n\x05Monty"
-	`, pb)
-	t.Logf("result: %v (error: %v)", expandedMarshaler.Text(pb), err)
-	if err != nil {
-		t.Errorf("failed to parse ambiguous Any message: %v", err)
-	}
-}
-
-func TestUnmarshalOverwriteAny(t *testing.T) {
-	pb := &anypb.Any{}
-	err := proto.UnmarshalText(`
-  [type.googleapis.com/a/path/proto3_proto.Nested]: <
-    bunny: "Monty"
-  >
-  [type.googleapis.com/a/path/proto3_proto.Nested]: <
-    bunny: "Rabbit of Caerbannog"
-  >
-	`, pb)
-	want := `line 7: Any message unpacked multiple times, or "type_url" already set`
-	if err.Error() != want {
-		t.Errorf("incorrect error.\nHave: %v\nWant: %v", err.Error(), want)
-	}
-}
-
-func TestUnmarshalAnyMixAndMatch(t *testing.T) {
-	pb := &anypb.Any{}
-	err := proto.UnmarshalText(`
-	value: "\n\x05Monty"
-  [type.googleapis.com/a/path/proto3_proto.Nested]: <
-    bunny: "Rabbit of Caerbannog"
-  >
-	`, pb)
-	want := `line 5: Any message unpacked multiple times, or "value" already set`
-	if err.Error() != want {
-		t.Errorf("incorrect error.\nHave: %v\nWant: %v", err.Error(), want)
-	}
-}
diff --git a/proto/hooks_disabled.go b/proto/hooks_disabled.go
index b604f81..96e9b34 100644
--- a/proto/hooks_disabled.go
+++ b/proto/hooks_disabled.go
@@ -7,9 +7,11 @@
 package proto
 
 import (
+	"io"
 	"reflect"
 
 	descriptorpb "github.com/golang/protobuf/v2/types/descriptor"
+	knownpb "github.com/golang/protobuf/v2/types/known"
 )
 
 var (
@@ -30,8 +32,23 @@
 	fileDescriptorAlt       func(string) []byte
 	registerExtensionAlt    func(*ExtensionDesc)
 	registeredExtensionsAlt func(Message) map[int32]*ExtensionDesc
+
+	// Hooks for text.go
+	marshalTextAlt       func(io.Writer, Message) error
+	marshalTextStringAlt func(Message) string
+	compactTextAlt       func(io.Writer, Message) error
+	compactTextStringAlt func(Message) string
+
+	// Hooks for text_parser.go
+	unmarshalTextAlt func(string, Message) error
 )
 
+// Hooks for lib.go.
+type RequiredNotSetError = requiredNotSetError
+
+// Hooks for text.go
+type TextMarshaler = textMarshaler
+
 // The v2 descriptor no longer registers with v1.
 // If we're only relying on the v1 registry, we need to manually register the
 // types in descriptor.
@@ -73,4 +90,54 @@
 	RegisterType((*descriptorpb.UninterpretedOption_NamePart)(nil), "google.protobuf.UninterpretedOption.NamePart")
 	RegisterType((*descriptorpb.SourceCodeInfo_Location)(nil), "google.protobuf.SourceCodeInfo.Location")
 	RegisterType((*descriptorpb.GeneratedCodeInfo_Annotation)(nil), "google.protobuf.GeneratedCodeInfo.Annotation")
+
+	// any.proto
+	RegisterType((*knownpb.Any)(nil), "google.protobuf.Any")
+
+	// api.proto
+	RegisterType((*knownpb.Api)(nil), "google.protobuf.Api")
+	RegisterType((*knownpb.Method)(nil), "google.protobuf.Method")
+	RegisterType((*knownpb.Mixin)(nil), "google.protobuf.Mixin")
+
+	// duration.proto
+	RegisterType((*knownpb.Duration)(nil), "google.protobuf.Duration")
+
+	// empty.proto
+	RegisterType((*knownpb.Empty)(nil), "google.protobuf.Empty")
+
+	// field_mask.proto
+	RegisterType((*knownpb.FieldMask)(nil), "google.protobuf.FieldMask")
+
+	// source_context.proto
+	RegisterType((*knownpb.SourceContext)(nil), "google.protobuf.SourceContext")
+
+	// struct.proto
+	RegisterEnum("google.protobuf.NullValue", knownpb.NullValue_name, knownpb.NullValue_value)
+	RegisterType((*knownpb.Struct)(nil), "google.protobuf.Struct")
+	RegisterType((*knownpb.Value)(nil), "google.protobuf.Value")
+	RegisterType((*knownpb.ListValue)(nil), "google.protobuf.ListValue")
+
+	// timestamp.proto
+	RegisterType((*knownpb.Timestamp)(nil), "google.protobuf.Timestamp")
+
+	// type.proto
+	RegisterEnum("google.protobuf.Syntax", knownpb.Syntax_name, knownpb.Syntax_value)
+	RegisterEnum("google.protobuf.Field_Kind", knownpb.Field_Kind_name, knownpb.Field_Kind_value)
+	RegisterEnum("google.protobuf.Field_Cardinality", knownpb.Field_Cardinality_name, knownpb.Field_Cardinality_value)
+	RegisterType((*knownpb.Type)(nil), "google.protobuf.Type")
+	RegisterType((*knownpb.Field)(nil), "google.protobuf.Field")
+	RegisterType((*knownpb.Enum)(nil), "google.protobuf.Enum")
+	RegisterType((*knownpb.EnumValue)(nil), "google.protobuf.EnumValue")
+	RegisterType((*knownpb.Option)(nil), "google.protobuf.Option")
+
+	// wrapper.proto
+	RegisterType((*knownpb.DoubleValue)(nil), "google.protobuf.DoubleValue")
+	RegisterType((*knownpb.FloatValue)(nil), "google.protobuf.FloatValue")
+	RegisterType((*knownpb.Int64Value)(nil), "google.protobuf.Int64Value")
+	RegisterType((*knownpb.UInt64Value)(nil), "google.protobuf.UInt64Value")
+	RegisterType((*knownpb.Int32Value)(nil), "google.protobuf.Int32Value")
+	RegisterType((*knownpb.UInt32Value)(nil), "google.protobuf.UInt32Value")
+	RegisterType((*knownpb.BoolValue)(nil), "google.protobuf.BoolValue")
+	RegisterType((*knownpb.StringValue)(nil), "google.protobuf.StringValue")
+	RegisterType((*knownpb.BytesValue)(nil), "google.protobuf.BytesValue")
 }
diff --git a/proto/hooks_enabled.go b/proto/hooks_enabled.go
index 1c6e97f..67f3b01 100644
--- a/proto/hooks_enabled.go
+++ b/proto/hooks_enabled.go
@@ -28,4 +28,19 @@
 	fileDescriptorAlt       = proto.FileDescriptor
 	registerExtensionAlt    = proto.RegisterExtension
 	registeredExtensionsAlt = proto.RegisteredExtensions
+
+	// Hooks for text.go
+	marshalTextAlt       = proto.MarshalText
+	marshalTextStringAlt = proto.MarshalTextString
+	compactTextAlt       = proto.CompactText
+	compactTextStringAlt = proto.CompactTextString
+
+	// Hooks for text_parser.go
+	unmarshalTextAlt = proto.UnmarshalText
 )
+
+// Hooks for lib.go.
+type RequiredNotSetError = proto.RequiredNotSetError
+
+// Hooks for text.go
+type TextMarshaler = proto.TextMarshaler
diff --git a/proto/lib.go b/proto/lib.go
index e82e138..77c596a 100644
--- a/proto/lib.go
+++ b/proto/lib.go
@@ -34,18 +34,18 @@
 	sync.Locker
 }
 
-// RequiredNotSetError is an error type returned by either Marshal or Unmarshal.
+// requiredNotSetError is an error type returned by either Marshal or Unmarshal.
 // Marshal reports this when a required field is not initialized.
 // Unmarshal reports this when a required field is missing from the wire data.
-type RequiredNotSetError struct{ field string }
+type requiredNotSetError struct{ field string }
 
-func (e *RequiredNotSetError) Error() string {
+func (e *requiredNotSetError) Error() string {
 	if e.field == "" {
 		return fmt.Sprintf("proto: required field not set")
 	}
 	return fmt.Sprintf("proto: required field %q not set", e.field)
 }
-func (e *RequiredNotSetError) RequiredNotSet() bool {
+func (e *requiredNotSetError) RequiredNotSet() bool {
 	return true
 }
 
diff --git a/proto/table_marshal.go b/proto/table_marshal.go
index 303c1ea..7ec867e 100644
--- a/proto/table_marshal.go
+++ b/proto/table_marshal.go
@@ -234,7 +234,7 @@
 				// Required field is not set.
 				// We record the error but keep going, to give a complete marshaling.
 				if errLater == nil {
-					errLater = &RequiredNotSetError{f.name}
+					errLater = &requiredNotSetError{f.name}
 				}
 				continue
 			}
@@ -245,11 +245,11 @@
 		}
 		b, err = f.marshaler(b, ptr.offset(f.field), f.wiretag, deterministic)
 		if err != nil {
-			if err1, ok := err.(*RequiredNotSetError); ok {
+			if err1, ok := err.(*requiredNotSetError); ok {
 				// Required field in submessage is not set.
 				// We record the error but keep going, to give a complete marshaling.
 				if errLater == nil {
-					errLater = &RequiredNotSetError{f.name + "." + err1.field}
+					errLater = &requiredNotSetError{f.name + "." + err1.field}
 				}
 				continue
 			}
diff --git a/proto/table_unmarshal.go b/proto/table_unmarshal.go
index ae4395f..87d3da7 100644
--- a/proto/table_unmarshal.go
+++ b/proto/table_unmarshal.go
@@ -151,7 +151,7 @@
 				reqMask |= f.reqMask
 				continue
 			}
-			if r, ok := err.(*RequiredNotSetError); ok {
+			if r, ok := err.(*requiredNotSetError); ok {
 				// Remember this error, but keep parsing. We need to produce
 				// a full parse even if a required field is missing.
 				if errLater == nil {
@@ -227,7 +227,7 @@
 		// A required field of this message is missing.
 		for _, n := range u.reqFields {
 			if reqMask&1 == 0 {
-				errLater = &RequiredNotSetError{n}
+				errLater = &requiredNotSetError{n}
 			}
 			reqMask >>= 1
 		}
@@ -1618,7 +1618,7 @@
 		}
 		err := sub.unmarshal(v, b[:x])
 		if err != nil {
-			if r, ok := err.(*RequiredNotSetError); ok {
+			if r, ok := err.(*requiredNotSetError); ok {
 				r.field = name + "." + r.field
 			} else {
 				return nil, err
@@ -1644,7 +1644,7 @@
 		v := valToPointer(reflect.New(sub.typ))
 		err := sub.unmarshal(v, b[:x])
 		if err != nil {
-			if r, ok := err.(*RequiredNotSetError); ok {
+			if r, ok := err.(*requiredNotSetError); ok {
 				r.field = name + "." + r.field
 			} else {
 				return nil, err
@@ -1671,7 +1671,7 @@
 		}
 		err := sub.unmarshal(v, b[:x])
 		if err != nil {
-			if r, ok := err.(*RequiredNotSetError); ok {
+			if r, ok := err.(*requiredNotSetError); ok {
 				r.field = name + "." + r.field
 			} else {
 				return nil, err
@@ -1693,7 +1693,7 @@
 		v := valToPointer(reflect.New(sub.typ))
 		err := sub.unmarshal(v, b[:x])
 		if err != nil {
-			if r, ok := err.(*RequiredNotSetError); ok {
+			if r, ok := err.(*requiredNotSetError); ok {
 				r.field = name + "." + r.field
 			} else {
 				return nil, err
diff --git a/proto/text.go b/proto/text.go
index dfd3e92..647e10f 100644
--- a/proto/text.go
+++ b/proto/text.go
@@ -179,7 +179,7 @@
 //
 // It returns (true, error) when sv was written in expanded format or an error
 // was encountered.
-func (tm *TextMarshaler) writeProto3Any(w *textWriter, sv reflect.Value) (bool, error) {
+func (tm *textMarshaler) writeProto3Any(w *textWriter, sv reflect.Value) (bool, error) {
 	turl := sv.FieldByName("TypeUrl")
 	val := sv.FieldByName("Value")
 	if !turl.IsValid() || !val.IsValid() {
@@ -225,7 +225,7 @@
 	return true, nil
 }
 
-func (tm *TextMarshaler) writeStruct(w *textWriter, sv reflect.Value) error {
+func (tm *textMarshaler) writeStruct(w *textWriter, sv reflect.Value) error {
 	if tm.ExpandAny && isAny(sv) {
 		if canExpand, err := tm.writeProto3Any(w, sv); canExpand {
 			return err
@@ -432,7 +432,7 @@
 }
 
 // writeAny writes an arbitrary field.
-func (tm *TextMarshaler) writeAny(w *textWriter, v reflect.Value, props *Properties) error {
+func (tm *textMarshaler) writeAny(w *textWriter, v reflect.Value, props *Properties) error {
 	v = reflect.Indirect(v)
 
 	// Floats have special cases.
@@ -651,7 +651,7 @@
 
 // writeExtensions writes all the extensions in pv.
 // pv is assumed to be a pointer to a protocol message struct that is extendable.
-func (tm *TextMarshaler) writeExtensions(w *textWriter, pv reflect.Value) error {
+func (tm *textMarshaler) writeExtensions(w *textWriter, pv reflect.Value) error {
 	emap := RegisteredExtensions(pv.Interface().(Message))
 	ep, _ := extendable(pv.Interface())
 
@@ -706,7 +706,7 @@
 	return nil
 }
 
-func (tm *TextMarshaler) writeExtension(w *textWriter, name string, pb interface{}) error {
+func (tm *textMarshaler) writeExtension(w *textWriter, name string, pb interface{}) error {
 	if _, err := fmt.Fprintf(w, "[%s]:", name); err != nil {
 		return err
 	}
@@ -740,15 +740,15 @@
 	w.complete = false
 }
 
-// TextMarshaler is a configurable text format marshaler.
-type TextMarshaler struct {
+// textMarshaler is a configurable text format marshaler.
+type textMarshaler struct {
 	Compact   bool // use compact text format (one line).
 	ExpandAny bool // expand google.protobuf.Any messages of known types
 }
 
 // Marshal writes a given protocol buffer in text format.
 // The only errors returned are from w.
-func (tm *TextMarshaler) Marshal(w io.Writer, pb Message) error {
+func (tm *textMarshaler) Marshal(w io.Writer, pb Message) error {
 	val := reflect.ValueOf(pb)
 	if pb == nil || val.IsNil() {
 		w.Write([]byte("<nil>"))
@@ -791,28 +791,48 @@
 }
 
 // Text is the same as Marshal, but returns the string directly.
-func (tm *TextMarshaler) Text(pb Message) string {
+func (tm *textMarshaler) Text(pb Message) string {
 	var buf bytes.Buffer
 	tm.Marshal(&buf, pb)
 	return buf.String()
 }
 
 var (
-	defaultTextMarshaler = TextMarshaler{}
-	compactTextMarshaler = TextMarshaler{Compact: true}
+	defaultTextMarshaler = textMarshaler{}
+	compactTextMarshaler = textMarshaler{Compact: true}
 )
 
 // TODO: consider removing some of the Marshal functions below.
 
 // MarshalText writes a given protocol buffer in text format.
 // The only errors returned are from w.
-func MarshalText(w io.Writer, pb Message) error { return defaultTextMarshaler.Marshal(w, pb) }
+func MarshalText(w io.Writer, pb Message) error {
+	if marshalTextAlt != nil {
+		return marshalTextAlt(w, pb)
+	}
+	return defaultTextMarshaler.Marshal(w, pb)
+}
 
 // MarshalTextString is the same as MarshalText, but returns the string directly.
-func MarshalTextString(pb Message) string { return defaultTextMarshaler.Text(pb) }
+func MarshalTextString(pb Message) string {
+	if marshalTextStringAlt != nil {
+		return marshalTextStringAlt(pb)
+	}
+	return defaultTextMarshaler.Text(pb)
+}
 
 // CompactText writes a given protocol buffer in compact text format (one line).
-func CompactText(w io.Writer, pb Message) error { return compactTextMarshaler.Marshal(w, pb) }
+func CompactText(w io.Writer, pb Message) error {
+	if compactTextAlt != nil {
+		return compactTextAlt(w, pb)
+	}
+	return compactTextMarshaler.Marshal(w, pb)
+}
 
 // CompactTextString is the same as CompactText, but returns the string directly.
-func CompactTextString(pb Message) string { return compactTextMarshaler.Text(pb) }
+func CompactTextString(pb Message) string {
+	if compactTextStringAlt != nil {
+		return compactTextStringAlt(pb)
+	}
+	return compactTextMarshaler.Text(pb)
+}
diff --git a/proto/text_parser.go b/proto/text_parser.go
index 96a7833..443f627 100644
--- a/proto/text_parser.go
+++ b/proto/text_parser.go
@@ -338,8 +338,8 @@
 	return nil
 }
 
-// Return a RequiredNotSetError indicating which required field was not set.
-func (p *textParser) missingRequiredFieldError(sv reflect.Value) *RequiredNotSetError {
+// Return a requiredNotSetError indicating which required field was not set.
+func (p *textParser) missingRequiredFieldError(sv reflect.Value) *requiredNotSetError {
 	st := sv.Type()
 	sprops := GetProperties(st)
 	for i := 0; i < st.NumField(); i++ {
@@ -349,10 +349,10 @@
 
 		props := sprops.Prop[i]
 		if props.Required {
-			return &RequiredNotSetError{fmt.Sprintf("%v.%v", st, props.OrigName)}
+			return &requiredNotSetError{fmt.Sprintf("%v.%v", st, props.OrigName)}
 		}
 	}
-	return &RequiredNotSetError{fmt.Sprintf("%v.<unknown field name>", st)} // should not happen
+	return &requiredNotSetError{fmt.Sprintf("%v.<unknown field name>", st)} // should not happen
 }
 
 // Returns the index in the struct for the named field, as well as the parsed tag properties.
@@ -549,7 +549,7 @@
 				ext = reflect.New(typ.Elem()).Elem()
 			}
 			if err := p.readAny(ext, props); err != nil {
-				if _, ok := err.(*RequiredNotSetError); !ok {
+				if _, ok := err.(*requiredNotSetError); !ok {
 					return err
 				}
 				reqFieldErr = err
@@ -675,7 +675,7 @@
 		// Parse into the field.
 		fieldSet[name] = true
 		if err := p.readAny(dst, props); err != nil {
-			if _, ok := err.(*RequiredNotSetError); !ok {
+			if _, ok := err.(*requiredNotSetError); !ok {
 				return err
 			}
 			reqFieldErr = err
@@ -876,8 +876,11 @@
 // UnmarshalText reads a protocol buffer in Text format. UnmarshalText resets pb
 // before starting to unmarshal, so any existing data in pb is always removed.
 // If a required field is not set and no other error occurs,
-// UnmarshalText returns *RequiredNotSetError.
+// UnmarshalText returns *requiredNotSetError.
 func UnmarshalText(s string, pb Message) error {
+	if unmarshalTextAlt != nil {
+		return unmarshalTextAlt(s, pb) // populated by hooks_enabled.go
+	}
 	if um, ok := pb.(encoding.TextUnmarshaler); ok {
 		return um.UnmarshalText([]byte(s))
 	}
diff --git a/proto/text_parser_test.go b/proto/text_parser_test.go
deleted file mode 100644
index e0a8927..0000000
--- a/proto/text_parser_test.go
+++ /dev/null
@@ -1,679 +0,0 @@
-// Copyright 2010 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package proto_test
-
-import (
-	"fmt"
-	"math"
-	"testing"
-
-	. "github.com/golang/protobuf/proto"
-	proto3pb "github.com/golang/protobuf/proto/proto3_proto"
-	. "github.com/golang/protobuf/proto/test_proto"
-)
-
-type UnmarshalTextTest struct {
-	in  string
-	err string // if "", no error expected
-	out *MyMessage
-}
-
-func buildExtStructTest(text string) UnmarshalTextTest {
-	msg := &MyMessage{
-		Count: Int32(42),
-	}
-	SetExtension(msg, E_Ext_More, &Ext{
-		Data: String("Hello, world!"),
-	})
-	return UnmarshalTextTest{in: text, out: msg}
-}
-
-func buildExtDataTest(text string) UnmarshalTextTest {
-	msg := &MyMessage{
-		Count: Int32(42),
-	}
-	SetExtension(msg, E_Ext_Text, String("Hello, world!"))
-	SetExtension(msg, E_Ext_Number, Int32(1729))
-	return UnmarshalTextTest{in: text, out: msg}
-}
-
-func buildExtRepStringTest(text string) UnmarshalTextTest {
-	msg := &MyMessage{
-		Count: Int32(42),
-	}
-	if err := SetExtension(msg, E_Greeting, []string{"bula", "hola"}); err != nil {
-		panic(err)
-	}
-	return UnmarshalTextTest{in: text, out: msg}
-}
-
-var unMarshalTextTests = []UnmarshalTextTest{
-	// Basic
-	{
-		in: " count:42\n  name:\"Dave\" ",
-		out: &MyMessage{
-			Count: Int32(42),
-			Name:  String("Dave"),
-		},
-	},
-
-	// Empty quoted string
-	{
-		in: `count:42 name:""`,
-		out: &MyMessage{
-			Count: Int32(42),
-			Name:  String(""),
-		},
-	},
-
-	// Quoted string concatenation with double quotes
-	{
-		in: `count:42 name: "My name is "` + "\n" + `"elsewhere"`,
-		out: &MyMessage{
-			Count: Int32(42),
-			Name:  String("My name is elsewhere"),
-		},
-	},
-
-	// Quoted string concatenation with single quotes
-	{
-		in: "count:42 name: 'My name is '\n'elsewhere'",
-		out: &MyMessage{
-			Count: Int32(42),
-			Name:  String("My name is elsewhere"),
-		},
-	},
-
-	// Quoted string concatenations with mixed quotes
-	{
-		in: "count:42 name: 'My name is '\n\"elsewhere\"",
-		out: &MyMessage{
-			Count: Int32(42),
-			Name:  String("My name is elsewhere"),
-		},
-	},
-	{
-		in: "count:42 name: \"My name is \"\n'elsewhere'",
-		out: &MyMessage{
-			Count: Int32(42),
-			Name:  String("My name is elsewhere"),
-		},
-	},
-
-	// Quoted string with escaped apostrophe
-	{
-		in: `count:42 name: "HOLIDAY - New Year\'s Day"`,
-		out: &MyMessage{
-			Count: Int32(42),
-			Name:  String("HOLIDAY - New Year's Day"),
-		},
-	},
-
-	// Quoted string with single quote
-	{
-		in: `count:42 name: 'Roger "The Ramster" Ramjet'`,
-		out: &MyMessage{
-			Count: Int32(42),
-			Name:  String(`Roger "The Ramster" Ramjet`),
-		},
-	},
-
-	// Quoted string with all the accepted special characters from the C++ test
-	{
-		in: `count:42 name: ` + "\"\\\"A string with \\' characters \\n and \\r newlines and \\t tabs and \\001 slashes \\\\ and  multiple   spaces\"",
-		out: &MyMessage{
-			Count: Int32(42),
-			Name:  String("\"A string with ' characters \n and \r newlines and \t tabs and \001 slashes \\ and  multiple   spaces"),
-		},
-	},
-
-	// Quoted string with quoted backslash
-	{
-		in: `count:42 name: "\\'xyz"`,
-		out: &MyMessage{
-			Count: Int32(42),
-			Name:  String(`\'xyz`),
-		},
-	},
-
-	// Quoted string with UTF-8 bytes.
-	{
-		in: "count:42 name: '\303\277\302\201\x00\xAB\xCD\xEF'",
-		out: &MyMessage{
-			Count: Int32(42),
-			Name:  String("\303\277\302\201\x00\xAB\xCD\xEF"),
-		},
-	},
-
-	// Quoted string with unicode escapes.
-	{
-		in: `count: 42 name: "\u0047\U00000047\uffff\U0010ffff"`,
-		out: &MyMessage{
-			Count: Int32(42),
-			Name:  String("GG\uffff\U0010ffff"),
-		},
-	},
-
-	// Bad quoted string
-	{
-		in:  `inner: < host: "\0" >` + "\n",
-		err: `line 1.15: invalid quoted string "\0": \0 requires 2 following digits`,
-	},
-
-	// Bad \u escape
-	{
-		in:  `count: 42 name: "\u000"`,
-		err: `line 1.16: invalid quoted string "\u000": \u requires 4 following digits`,
-	},
-
-	// Bad \U escape
-	{
-		in:  `count: 42 name: "\U0000000"`,
-		err: `line 1.16: invalid quoted string "\U0000000": \U requires 8 following digits`,
-	},
-
-	// Bad \U escape
-	{
-		in:  `count: 42 name: "\xxx"`,
-		err: `line 1.16: invalid quoted string "\xxx": \xxx contains non-hexadecimal digits`,
-	},
-
-	// Number too large for int64
-	{
-		in:  "count: 1 others { key: 123456789012345678901 }",
-		err: "line 1.23: invalid int64: 123456789012345678901",
-	},
-
-	// Number too large for int32
-	{
-		in:  "count: 1234567890123",
-		err: "line 1.7: invalid int32: 1234567890123",
-	},
-
-	// Number in hexadecimal
-	{
-		in: "count: 0x2beef",
-		out: &MyMessage{
-			Count: Int32(0x2beef),
-		},
-	},
-
-	// Number in octal
-	{
-		in: "count: 024601",
-		out: &MyMessage{
-			Count: Int32(024601),
-		},
-	},
-
-	// Floating point number with "f" suffix
-	{
-		in: "count: 4 others:< weight: 17.0f >",
-		out: &MyMessage{
-			Count: Int32(4),
-			Others: []*OtherMessage{
-				{
-					Weight: Float32(17),
-				},
-			},
-		},
-	},
-
-	// Floating point positive infinity
-	{
-		in: "count: 4 bigfloat: inf",
-		out: &MyMessage{
-			Count:    Int32(4),
-			Bigfloat: Float64(math.Inf(1)),
-		},
-	},
-
-	// Floating point negative infinity
-	{
-		in: "count: 4 bigfloat: -inf",
-		out: &MyMessage{
-			Count:    Int32(4),
-			Bigfloat: Float64(math.Inf(-1)),
-		},
-	},
-
-	// Number too large for float32
-	{
-		in:  "others:< weight: 12345678901234567890123456789012345678901234567890 >",
-		err: "line 1.17: invalid float32: 12345678901234567890123456789012345678901234567890",
-	},
-
-	// Number posing as a quoted string
-	{
-		in:  `inner: < host: 12 >` + "\n",
-		err: `line 1.15: invalid string: 12`,
-	},
-
-	// Quoted string posing as int32
-	{
-		in:  `count: "12"`,
-		err: `line 1.7: invalid int32: "12"`,
-	},
-
-	// Quoted string posing a float32
-	{
-		in:  `others:< weight: "17.4" >`,
-		err: `line 1.17: invalid float32: "17.4"`,
-	},
-
-	// unclosed bracket doesn't cause infinite loop
-	{
-		in:  `[`,
-		err: `line 1.0: unclosed type_url or extension name`,
-	},
-
-	// Enum
-	{
-		in: `count:42 bikeshed: BLUE`,
-		out: &MyMessage{
-			Count:    Int32(42),
-			Bikeshed: MyMessage_BLUE.Enum(),
-		},
-	},
-
-	// Repeated field
-	{
-		in: `count:42 pet: "horsey" pet:"bunny"`,
-		out: &MyMessage{
-			Count: Int32(42),
-			Pet:   []string{"horsey", "bunny"},
-		},
-	},
-
-	// Repeated field with list notation
-	{
-		in: `count:42 pet: ["horsey", "bunny"]`,
-		out: &MyMessage{
-			Count: Int32(42),
-			Pet:   []string{"horsey", "bunny"},
-		},
-	},
-
-	// Repeated message with/without colon and <>/{}
-	{
-		in: `count:42 others:{} others{} others:<> others:{}`,
-		out: &MyMessage{
-			Count: Int32(42),
-			Others: []*OtherMessage{
-				{},
-				{},
-				{},
-				{},
-			},
-		},
-	},
-
-	// Missing colon for inner message
-	{
-		in: `count:42 inner < host: "cauchy.syd" >`,
-		out: &MyMessage{
-			Count: Int32(42),
-			Inner: &InnerMessage{
-				Host: String("cauchy.syd"),
-			},
-		},
-	},
-
-	// Missing colon for string field
-	{
-		in:  `name "Dave"`,
-		err: `line 1.5: expected ':', found "\"Dave\""`,
-	},
-
-	// Missing colon for int32 field
-	{
-		in:  `count 42`,
-		err: `line 1.6: expected ':', found "42"`,
-	},
-
-	// Missing required field
-	{
-		in:  `name: "Pawel"`,
-		err: fmt.Sprintf(`proto: required field "%T.count" not set`, MyMessage{}),
-		out: &MyMessage{
-			Name: String("Pawel"),
-		},
-	},
-
-	// Missing required field in a required submessage
-	{
-		in:  `count: 42 we_must_go_deeper < leo_finally_won_an_oscar <> >`,
-		err: fmt.Sprintf(`proto: required field "%T.host" not set`, InnerMessage{}),
-		out: &MyMessage{
-			Count:          Int32(42),
-			WeMustGoDeeper: &RequiredInnerMessage{LeoFinallyWonAnOscar: &InnerMessage{}},
-		},
-	},
-
-	// Repeated non-repeated field
-	{
-		in:  `name: "Rob" name: "Russ"`,
-		err: `line 1.12: non-repeated field "name" was repeated`,
-	},
-
-	// Group
-	{
-		in: `count: 17 SomeGroup { group_field: 12 }`,
-		out: &MyMessage{
-			Count: Int32(17),
-			Somegroup: &MyMessage_SomeGroup{
-				GroupField: Int32(12),
-			},
-		},
-	},
-
-	// Semicolon between fields
-	{
-		in: `count:3;name:"Calvin"`,
-		out: &MyMessage{
-			Count: Int32(3),
-			Name:  String("Calvin"),
-		},
-	},
-	// Comma between fields
-	{
-		in: `count:4,name:"Ezekiel"`,
-		out: &MyMessage{
-			Count: Int32(4),
-			Name:  String("Ezekiel"),
-		},
-	},
-
-	// Boolean false
-	{
-		in: `count:42 inner { host: "example.com" connected: false }`,
-		out: &MyMessage{
-			Count: Int32(42),
-			Inner: &InnerMessage{
-				Host:      String("example.com"),
-				Connected: Bool(false),
-			},
-		},
-	},
-	// Boolean true
-	{
-		in: `count:42 inner { host: "example.com" connected: true }`,
-		out: &MyMessage{
-			Count: Int32(42),
-			Inner: &InnerMessage{
-				Host:      String("example.com"),
-				Connected: Bool(true),
-			},
-		},
-	},
-	// Boolean 0
-	{
-		in: `count:42 inner { host: "example.com" connected: 0 }`,
-		out: &MyMessage{
-			Count: Int32(42),
-			Inner: &InnerMessage{
-				Host:      String("example.com"),
-				Connected: Bool(false),
-			},
-		},
-	},
-	// Boolean 1
-	{
-		in: `count:42 inner { host: "example.com" connected: 1 }`,
-		out: &MyMessage{
-			Count: Int32(42),
-			Inner: &InnerMessage{
-				Host:      String("example.com"),
-				Connected: Bool(true),
-			},
-		},
-	},
-	// Boolean f
-	{
-		in: `count:42 inner { host: "example.com" connected: f }`,
-		out: &MyMessage{
-			Count: Int32(42),
-			Inner: &InnerMessage{
-				Host:      String("example.com"),
-				Connected: Bool(false),
-			},
-		},
-	},
-	// Boolean t
-	{
-		in: `count:42 inner { host: "example.com" connected: t }`,
-		out: &MyMessage{
-			Count: Int32(42),
-			Inner: &InnerMessage{
-				Host:      String("example.com"),
-				Connected: Bool(true),
-			},
-		},
-	},
-	// Boolean False
-	{
-		in: `count:42 inner { host: "example.com" connected: False }`,
-		out: &MyMessage{
-			Count: Int32(42),
-			Inner: &InnerMessage{
-				Host:      String("example.com"),
-				Connected: Bool(false),
-			},
-		},
-	},
-	// Boolean True
-	{
-		in: `count:42 inner { host: "example.com" connected: True }`,
-		out: &MyMessage{
-			Count: Int32(42),
-			Inner: &InnerMessage{
-				Host:      String("example.com"),
-				Connected: Bool(true),
-			},
-		},
-	},
-
-	// Extension
-	buildExtStructTest(`count: 42 [test_proto.Ext.more]:<data:"Hello, world!" >`),
-	buildExtStructTest(`count: 42 [test_proto.Ext.more] {data:"Hello, world!"}`),
-	buildExtDataTest(`count: 42 [test_proto.Ext.text]:"Hello, world!" [test_proto.Ext.number]:1729`),
-	buildExtRepStringTest(`count: 42 [test_proto.greeting]:"bula" [test_proto.greeting]:"hola"`),
-
-	// Big all-in-one
-	{
-		in: "count:42  # Meaning\n" +
-			`name:"Dave" ` +
-			`quote:"\"I didn't want to go.\"" ` +
-			`pet:"bunny" ` +
-			`pet:"kitty" ` +
-			`pet:"horsey" ` +
-			`inner:<` +
-			`  host:"footrest.syd" ` +
-			`  port:7001 ` +
-			`  connected:true ` +
-			`> ` +
-			`others:<` +
-			`  key:3735928559 ` +
-			`  value:"\x01A\a\f" ` +
-			`> ` +
-			`others:<` +
-			"  weight:58.9  # Atomic weight of Co\n" +
-			`  inner:<` +
-			`    host:"lesha.mtv" ` +
-			`    port:8002 ` +
-			`  >` +
-			`>`,
-		out: &MyMessage{
-			Count: Int32(42),
-			Name:  String("Dave"),
-			Quote: String(`"I didn't want to go."`),
-			Pet:   []string{"bunny", "kitty", "horsey"},
-			Inner: &InnerMessage{
-				Host:      String("footrest.syd"),
-				Port:      Int32(7001),
-				Connected: Bool(true),
-			},
-			Others: []*OtherMessage{
-				{
-					Key:   Int64(3735928559),
-					Value: []byte{0x1, 'A', '\a', '\f'},
-				},
-				{
-					Weight: Float32(58.9),
-					Inner: &InnerMessage{
-						Host: String("lesha.mtv"),
-						Port: Int32(8002),
-					},
-				},
-			},
-		},
-	},
-}
-
-func TestUnmarshalText(t *testing.T) {
-	for i, test := range unMarshalTextTests {
-		pb := new(MyMessage)
-		err := UnmarshalText(test.in, pb)
-		if test.err == "" {
-			// We don't expect failure.
-			if err != nil {
-				t.Errorf("Test %d: Unexpected error: %v", i, err)
-			} else if !Equal(pb, test.out) {
-				t.Errorf("Test %d: Incorrect populated \nHave: %v\nWant: %v",
-					i, pb, test.out)
-			}
-		} else {
-			// We do expect failure.
-			if err == nil {
-				t.Errorf("Test %d: Didn't get expected error: %v", i, test.err)
-			} else if err.Error() != test.err {
-				t.Errorf("Test %d: Incorrect error.\nHave: %v\nWant: %v",
-					i, err.Error(), test.err)
-			} else if _, ok := err.(*RequiredNotSetError); ok && test.out != nil && !Equal(pb, test.out) {
-				t.Errorf("Test %d: Incorrect populated \nHave: %v\nWant: %v",
-					i, pb, test.out)
-			}
-		}
-	}
-}
-
-func TestUnmarshalTextCustomMessage(t *testing.T) {
-	msg := &textMessage{}
-	if err := UnmarshalText("custom", msg); err != nil {
-		t.Errorf("Unexpected error from custom unmarshal: %v", err)
-	}
-	if UnmarshalText("not custom", msg) == nil {
-		t.Errorf("Didn't get expected error from custom unmarshal")
-	}
-}
-
-// Regression test; this caused a panic.
-func TestRepeatedEnum(t *testing.T) {
-	pb := new(RepeatedEnum)
-	if err := UnmarshalText("color: RED", pb); err != nil {
-		t.Fatal(err)
-	}
-	exp := &RepeatedEnum{
-		Color: []RepeatedEnum_Color{RepeatedEnum_RED},
-	}
-	if !Equal(pb, exp) {
-		t.Errorf("Incorrect populated \nHave: %v\nWant: %v", pb, exp)
-	}
-}
-
-func TestProto3TextParsing(t *testing.T) {
-	m := new(proto3pb.Message)
-	const in = `name: "Wallace" true_scotsman: true`
-	want := &proto3pb.Message{
-		Name:         "Wallace",
-		TrueScotsman: true,
-	}
-	if err := UnmarshalText(in, m); err != nil {
-		t.Fatal(err)
-	}
-	if !Equal(m, want) {
-		t.Errorf("\n got %v\nwant %v", m, want)
-	}
-}
-
-func TestMapParsing(t *testing.T) {
-	m := new(MessageWithMap)
-	const in = `name_mapping:<key:1234 value:"Feist"> name_mapping:<key:1 value:"Beatles">` +
-		`msg_mapping:<key:-4, value:<f: 2.0>,>` + // separating commas are okay
-		`msg_mapping<key:-2 value<f: 4.0>>` + // no colon after "value"
-		`msg_mapping:<value:<f: 5.0>>` + // omitted key
-		`msg_mapping:<key:1>` + // omitted value
-		`byte_mapping:<key:true value:"so be it">` +
-		`byte_mapping:<>` // omitted key and value
-	want := &MessageWithMap{
-		NameMapping: map[int32]string{
-			1:    "Beatles",
-			1234: "Feist",
-		},
-		MsgMapping: map[int64]*FloatingPoint{
-			-4: {F: Float64(2.0)},
-			-2: {F: Float64(4.0)},
-			0:  {F: Float64(5.0)},
-			1:  nil,
-		},
-		ByteMapping: map[bool][]byte{
-			false: nil,
-			true:  []byte("so be it"),
-		},
-	}
-	if err := UnmarshalText(in, m); err != nil {
-		t.Fatal(err)
-	}
-	if !Equal(m, want) {
-		t.Errorf("\n got %v\nwant %v", m, want)
-	}
-}
-
-func TestOneofParsing(t *testing.T) {
-	const in = `name:"Shrek"`
-	m := new(Communique)
-	want := &Communique{Union: &Communique_Name{"Shrek"}}
-	if err := UnmarshalText(in, m); err != nil {
-		t.Fatal(err)
-	}
-	if !Equal(m, want) {
-		t.Errorf("\n got %v\nwant %v", m, want)
-	}
-
-	const inOverwrite = `name:"Shrek" number:42`
-	m = new(Communique)
-	testErr := "line 1.13: field 'number' would overwrite already parsed oneof 'Union'"
-	if err := UnmarshalText(inOverwrite, m); err == nil {
-		t.Errorf("TestOneofParsing: Didn't get expected error: %v", testErr)
-	} else if err.Error() != testErr {
-		t.Errorf("TestOneofParsing: Incorrect error.\nHave: %v\nWant: %v",
-			err.Error(), testErr)
-	}
-
-}
-
-var benchInput string
-
-func init() {
-	benchInput = "count: 4\n"
-	for i := 0; i < 1000; i++ {
-		benchInput += "pet: \"fido\"\n"
-	}
-
-	// Check it is valid input.
-	pb := new(MyMessage)
-	err := UnmarshalText(benchInput, pb)
-	if err != nil {
-		panic("Bad benchmark input: " + err.Error())
-	}
-}
-
-func BenchmarkUnmarshalText(b *testing.B) {
-	pb := new(MyMessage)
-	for i := 0; i < b.N; i++ {
-		UnmarshalText(benchInput, pb)
-	}
-	b.SetBytes(int64(len(benchInput)))
-}
diff --git a/proto/text_test.go b/proto/text_test.go
deleted file mode 100644
index 2ff67af..0000000
--- a/proto/text_test.go
+++ /dev/null
@@ -1,491 +0,0 @@
-// Copyright 2010 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package proto_test
-
-import (
-	"bytes"
-	"errors"
-	"io/ioutil"
-	"math"
-	"strings"
-	"sync"
-	"testing"
-
-	"github.com/golang/protobuf/proto"
-
-	proto3pb "github.com/golang/protobuf/proto/proto3_proto"
-	pb "github.com/golang/protobuf/proto/test_proto"
-	anypb "github.com/golang/protobuf/ptypes/any"
-)
-
-// textMessage implements the methods that allow it to marshal and unmarshal
-// itself as text.
-type textMessage struct {
-}
-
-func (*textMessage) MarshalText() ([]byte, error) {
-	return []byte("custom"), nil
-}
-
-func (*textMessage) UnmarshalText(bytes []byte) error {
-	if string(bytes) != "custom" {
-		return errors.New("expected 'custom'")
-	}
-	return nil
-}
-
-func (*textMessage) Reset()         {}
-func (*textMessage) String() string { return "" }
-func (*textMessage) ProtoMessage()  {}
-
-func newTestMessage() *pb.MyMessage {
-	msg := &pb.MyMessage{
-		Count: proto.Int32(42),
-		Name:  proto.String("Dave"),
-		Quote: proto.String(`"I didn't want to go."`),
-		Pet:   []string{"bunny", "kitty", "horsey"},
-		Inner: &pb.InnerMessage{
-			Host:      proto.String("footrest.syd"),
-			Port:      proto.Int32(7001),
-			Connected: proto.Bool(true),
-		},
-		Others: []*pb.OtherMessage{
-			{
-				Key:   proto.Int64(0xdeadbeef),
-				Value: []byte{1, 65, 7, 12},
-			},
-			{
-				Weight: proto.Float32(6.022),
-				Inner: &pb.InnerMessage{
-					Host: proto.String("lesha.mtv"),
-					Port: proto.Int32(8002),
-				},
-			},
-		},
-		Bikeshed: pb.MyMessage_BLUE.Enum(),
-		Somegroup: &pb.MyMessage_SomeGroup{
-			GroupField: proto.Int32(8),
-		},
-		// One normally wouldn't do this.
-		// This is an undeclared tag 13, as a varint (wire type 0) with value 4.
-		XXX_unrecognized: []byte{13<<3 | 0, 4},
-	}
-	ext := &pb.Ext{
-		Data: proto.String("Big gobs for big rats"),
-	}
-	if err := proto.SetExtension(msg, pb.E_Ext_More, ext); err != nil {
-		panic(err)
-	}
-	greetings := []string{"adg", "easy", "cow"}
-	if err := proto.SetExtension(msg, pb.E_Greeting, greetings); err != nil {
-		panic(err)
-	}
-
-	// Add an unknown extension. We marshal a pb.Ext, and fake the ID.
-	b, err := proto.Marshal(&pb.Ext{Data: proto.String("3G skiing")})
-	if err != nil {
-		panic(err)
-	}
-	b = append(proto.EncodeVarint(201<<3|proto.WireBytes), b...)
-	proto.SetRawExtension(msg, 201, b)
-
-	// Extensions can be plain fields, too, so let's test that.
-	b = append(proto.EncodeVarint(202<<3|proto.WireVarint), 19)
-	proto.SetRawExtension(msg, 202, b)
-
-	return msg
-}
-
-const text = `count: 42
-name: "Dave"
-quote: "\"I didn't want to go.\""
-pet: "bunny"
-pet: "kitty"
-pet: "horsey"
-inner: <
-  host: "footrest.syd"
-  port: 7001
-  connected: true
->
-others: <
-  key: 3735928559
-  value: "\001A\007\014"
->
-others: <
-  weight: 6.022
-  inner: <
-    host: "lesha.mtv"
-    port: 8002
-  >
->
-bikeshed: BLUE
-SomeGroup {
-  group_field: 8
-}
-/* 2 unknown bytes */
-13: 4
-[test_proto.Ext.more]: <
-  data: "Big gobs for big rats"
->
-[test_proto.greeting]: "adg"
-[test_proto.greeting]: "easy"
-[test_proto.greeting]: "cow"
-/* 13 unknown bytes */
-201: "\t3G skiing"
-/* 3 unknown bytes */
-202: 19
-`
-
-func TestMarshalText(t *testing.T) {
-	buf := new(bytes.Buffer)
-	if err := proto.MarshalText(buf, newTestMessage()); err != nil {
-		t.Fatalf("proto.MarshalText: %v", err)
-	}
-	s := buf.String()
-	if s != text {
-		t.Errorf("Got:\n===\n%v===\nExpected:\n===\n%v===\n", s, text)
-	}
-}
-
-func TestMarshalTextCustomMessage(t *testing.T) {
-	buf := new(bytes.Buffer)
-	if err := proto.MarshalText(buf, &textMessage{}); err != nil {
-		t.Fatalf("proto.MarshalText: %v", err)
-	}
-	s := buf.String()
-	if s != "custom" {
-		t.Errorf("Got %q, expected %q", s, "custom")
-	}
-}
-func TestMarshalTextNil(t *testing.T) {
-	want := "<nil>"
-	tests := []proto.Message{nil, (*pb.MyMessage)(nil)}
-	for i, test := range tests {
-		buf := new(bytes.Buffer)
-		if err := proto.MarshalText(buf, test); err != nil {
-			t.Fatal(err)
-		}
-		if got := buf.String(); got != want {
-			t.Errorf("%d: got %q want %q", i, got, want)
-		}
-	}
-}
-
-func TestMarshalTextUnknownEnum(t *testing.T) {
-	// The Color enum only specifies values 0-2.
-	m := &pb.MyMessage{Bikeshed: pb.MyMessage_Color(3).Enum()}
-	got := m.String()
-	const want = `bikeshed:3 `
-	if got != want {
-		t.Errorf("\n got %q\nwant %q", got, want)
-	}
-}
-
-func TestTextOneof(t *testing.T) {
-	tests := []struct {
-		m    proto.Message
-		want string
-	}{
-		// zero message
-		{&pb.Communique{}, ``},
-		// scalar field
-		{&pb.Communique{Union: &pb.Communique_Number{4}}, `number:4`},
-		// message field
-		{&pb.Communique{Union: &pb.Communique_Msg{
-			&pb.Strings{StringField: proto.String("why hello!")},
-		}}, `msg:<string_field:"why hello!" >`},
-		// bad oneof (should not panic)
-		{&pb.Communique{Union: &pb.Communique_Msg{nil}}, `msg:/* nil */`},
-	}
-	for _, test := range tests {
-		got := strings.TrimSpace(test.m.String())
-		if got != test.want {
-			t.Errorf("\n got %s\nwant %s", got, test.want)
-		}
-	}
-}
-
-func BenchmarkMarshalTextBuffered(b *testing.B) {
-	buf := new(bytes.Buffer)
-	m := newTestMessage()
-	for i := 0; i < b.N; i++ {
-		buf.Reset()
-		proto.MarshalText(buf, m)
-	}
-}
-
-func BenchmarkMarshalTextUnbuffered(b *testing.B) {
-	w := ioutil.Discard
-	m := newTestMessage()
-	for i := 0; i < b.N; i++ {
-		proto.MarshalText(w, m)
-	}
-}
-
-func compact(src string) string {
-	// s/[ \n]+/ /g; s/ $//;
-	dst := make([]byte, len(src))
-	space, comment := false, false
-	j := 0
-	for i := 0; i < len(src); i++ {
-		if strings.HasPrefix(src[i:], "/*") {
-			comment = true
-			i++
-			continue
-		}
-		if comment && strings.HasPrefix(src[i:], "*/") {
-			comment = false
-			i++
-			continue
-		}
-		if comment {
-			continue
-		}
-		c := src[i]
-		if c == ' ' || c == '\n' {
-			space = true
-			continue
-		}
-		if j > 0 && (dst[j-1] == ':' || dst[j-1] == '<' || dst[j-1] == '{') {
-			space = false
-		}
-		if c == '{' {
-			space = false
-		}
-		if space {
-			dst[j] = ' '
-			j++
-			space = false
-		}
-		dst[j] = c
-		j++
-	}
-	if space {
-		dst[j] = ' '
-		j++
-	}
-	return string(dst[0:j])
-}
-
-var compactText = compact(text)
-
-func TestCompactText(t *testing.T) {
-	s := proto.CompactTextString(newTestMessage())
-	if s != compactText {
-		t.Errorf("Got:\n===\n%v===\nExpected:\n===\n%v\n===\n", s, compactText)
-	}
-}
-
-func TestStringEscaping(t *testing.T) {
-	testCases := []struct {
-		in  *pb.Strings
-		out string
-	}{
-		{
-			// Test data from C++ test (TextFormatTest.StringEscape).
-			// Single divergence: we don't escape apostrophes.
-			&pb.Strings{StringField: proto.String("\"A string with ' characters \n and \r newlines and \t tabs and \001 slashes \\ and  multiple   spaces")},
-			"string_field: \"\\\"A string with ' characters \\n and \\r newlines and \\t tabs and \\001 slashes \\\\ and  multiple   spaces\"\n",
-		},
-		{
-			// Test data from the same C++ test.
-			&pb.Strings{StringField: proto.String("\350\260\267\346\255\214")},
-			"string_field: \"\\350\\260\\267\\346\\255\\214\"\n",
-		},
-		{
-			// Some UTF-8.
-			&pb.Strings{StringField: proto.String("\x00\x01\xff\x81")},
-			`string_field: "\000\001\377\201"` + "\n",
-		},
-	}
-
-	for i, tc := range testCases {
-		var buf bytes.Buffer
-		if err := proto.MarshalText(&buf, tc.in); err != nil {
-			t.Errorf("proto.MarsalText: %v", err)
-			continue
-		}
-		s := buf.String()
-		if s != tc.out {
-			t.Errorf("#%d: Got:\n%s\nExpected:\n%s\n", i, s, tc.out)
-			continue
-		}
-
-		// Check round-trip.
-		pb := new(pb.Strings)
-		if err := proto.UnmarshalText(s, pb); err != nil {
-			t.Errorf("#%d: UnmarshalText: %v", i, err)
-			continue
-		}
-		if !proto.Equal(pb, tc.in) {
-			t.Errorf("#%d: Round-trip failed:\nstart: %v\n  end: %v", i, tc.in, pb)
-		}
-	}
-}
-
-// A limitedWriter accepts some output before it fails.
-// This is a proxy for something like a nearly-full or imminently-failing disk,
-// or a network connection that is about to die.
-type limitedWriter struct {
-	b     bytes.Buffer
-	limit int
-}
-
-var outOfSpace = errors.New("proto: insufficient space")
-
-func (w *limitedWriter) Write(p []byte) (n int, err error) {
-	var avail = w.limit - w.b.Len()
-	if avail <= 0 {
-		return 0, outOfSpace
-	}
-	if len(p) <= avail {
-		return w.b.Write(p)
-	}
-	n, _ = w.b.Write(p[:avail])
-	return n, outOfSpace
-}
-
-func TestMarshalTextFailing(t *testing.T) {
-	// Try lots of different sizes to exercise more error code-paths.
-	for lim := 0; lim < len(text); lim++ {
-		buf := new(limitedWriter)
-		buf.limit = lim
-		err := proto.MarshalText(buf, newTestMessage())
-		// We expect a certain error, but also some partial results in the buffer.
-		if err != outOfSpace {
-			t.Errorf("Got:\n===\n%v===\nExpected:\n===\n%v===\n", err, outOfSpace)
-		}
-		s := buf.b.String()
-		x := text[:buf.limit]
-		if s != x {
-			t.Errorf("Got:\n===\n%v===\nExpected:\n===\n%v===\n", s, x)
-		}
-	}
-}
-
-func TestFloats(t *testing.T) {
-	tests := []struct {
-		f    float64
-		want string
-	}{
-		{0, "0"},
-		{4.7, "4.7"},
-		{math.Inf(1), "inf"},
-		{math.Inf(-1), "-inf"},
-		{math.NaN(), "nan"},
-	}
-	for _, test := range tests {
-		msg := &pb.FloatingPoint{F: &test.f}
-		got := strings.TrimSpace(msg.String())
-		want := `f:` + test.want
-		if got != want {
-			t.Errorf("f=%f: got %q, want %q", test.f, got, want)
-		}
-	}
-}
-
-func TestRepeatedNilText(t *testing.T) {
-	m := &pb.MessageList{
-		Message: []*pb.MessageList_Message{
-			nil,
-			&pb.MessageList_Message{
-				Name: proto.String("Horse"),
-			},
-			nil,
-		},
-	}
-	want := `Message <nil>
-Message {
-  name: "Horse"
-}
-Message <nil>
-`
-	if s := proto.MarshalTextString(m); s != want {
-		t.Errorf(" got: %s\nwant: %s", s, want)
-	}
-}
-
-func TestProto3Text(t *testing.T) {
-	tests := []struct {
-		m    proto.Message
-		want string
-	}{
-		// zero message
-		{&proto3pb.Message{}, ``},
-		// zero message except for an empty byte slice
-		{&proto3pb.Message{Data: []byte{}}, ``},
-		// trivial case
-		{&proto3pb.Message{Name: "Rob", HeightInCm: 175}, `name:"Rob" height_in_cm:175`},
-		// empty map
-		{&pb.MessageWithMap{}, ``},
-		// non-empty map; map format is the same as a repeated struct,
-		// and they are sorted by key (numerically for numeric keys).
-		{
-			&pb.MessageWithMap{NameMapping: map[int32]string{
-				-1:      "Negatory",
-				7:       "Lucky",
-				1234:    "Feist",
-				6345789: "Otis",
-			}},
-			`name_mapping:<key:-1 value:"Negatory" > ` +
-				`name_mapping:<key:7 value:"Lucky" > ` +
-				`name_mapping:<key:1234 value:"Feist" > ` +
-				`name_mapping:<key:6345789 value:"Otis" >`,
-		},
-		// map with nil value; not well-defined, but we shouldn't crash
-		{
-			&pb.MessageWithMap{MsgMapping: map[int64]*pb.FloatingPoint{7: nil}},
-			`msg_mapping:<key:7 >`,
-		},
-	}
-	for _, test := range tests {
-		got := strings.TrimSpace(test.m.String())
-		if got != test.want {
-			t.Errorf("\n got %s\nwant %s", got, test.want)
-		}
-	}
-}
-
-func TestRacyMarshal(t *testing.T) {
-	// This test should be run with the race detector.
-
-	any := &pb.MyMessage{Count: proto.Int32(47), Name: proto.String("David")}
-	proto.SetExtension(any, pb.E_Ext_Text, proto.String("bar"))
-	b, err := proto.Marshal(any)
-	if err != nil {
-		panic(err)
-	}
-	m := &proto3pb.Message{
-		Name:        "David",
-		ResultCount: 47,
-		Anything:    &anypb.Any{TypeUrl: "type.googleapis.com/" + proto.MessageName(any), Value: b},
-	}
-
-	wantText := proto.MarshalTextString(m)
-	wantBytes, err := proto.Marshal(m)
-	if err != nil {
-		t.Fatalf("proto.Marshal error: %v", err)
-	}
-
-	var wg sync.WaitGroup
-	defer wg.Wait()
-	wg.Add(20)
-	for i := 0; i < 10; i++ {
-		go func() {
-			defer wg.Done()
-			got := proto.MarshalTextString(m)
-			if got != wantText {
-				t.Errorf("proto.MarshalTextString = %q, want %q", got, wantText)
-			}
-		}()
-		go func() {
-			defer wg.Done()
-			got, err := proto.Marshal(m)
-			if !bytes.Equal(got, wantBytes) || err != nil {
-				t.Errorf("proto.Marshal = (%x, %v), want (%x, nil)", got, err, wantBytes)
-			}
-		}()
-	}
-}
diff --git a/protoc-gen-go/descriptor/descriptor.pb.go b/protoc-gen-go/descriptor/descriptor.pb.go
index 6fc98ed..e165886 100644
--- a/protoc-gen-go/descriptor/descriptor.pb.go
+++ b/protoc-gen-go/descriptor/descriptor.pb.go
@@ -4,12 +4,15 @@
 package descriptor
 
 import (
-	proto "github.com/golang/protobuf/proto"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
+	protoregistry "github.com/golang/protobuf/v2/reflect/protoregistry"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 	descriptor "github.com/golang/protobuf/v2/types/descriptor"
+	sync "sync"
 )
 
+const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+
 // Symbols defined in public import of google/protobuf/descriptor.proto
 
 type FieldDescriptorProto_Type = descriptor.FieldDescriptorProto_Type
@@ -149,8 +152,9 @@
 type SourceCodeInfo_Location = descriptor.SourceCodeInfo_Location
 type GeneratedCodeInfo_Annotation = descriptor.GeneratedCodeInfo_Annotation
 
-var xxx_File_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto_rawdesc = []byte{
-	// 180 bytes of the wire-encoded FileDescriptorProto
+var File_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto protoreflect.FileDescriptor
+
+var xxx_File_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto_rawDesc = []byte{
 	0x0a, 0x44, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x6c,
 	0x61, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x72, 0x6f,
 	0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x67, 0x6f, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72,
@@ -165,11 +169,17 @@
 	0x6f, 0x74, 0x6f, 0x32,
 }
 
-var xxx_File_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto_rawdesc_gzipped = protoimpl.X.CompressGZIP(xxx_File_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto_rawdesc)
+var (
+	xxx_File_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto_rawDesc_once sync.Once
+	xxx_File_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto_rawDesc_data = xxx_File_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto_rawDesc
+)
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
-
-var File_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto protoreflect.FileDescriptor
+func xxx_File_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto_rawDescGZIP() []byte {
+	xxx_File_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto_rawDesc_once.Do(func() {
+		xxx_File_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto_rawDesc_data = protoimpl.X.CompressGZIP(xxx_File_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto_rawDesc_data)
+	})
+	return xxx_File_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto_rawDesc_data
+}
 
 var xxx_File_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto_goTypes = []interface{}{}
 var xxx_File_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto_depIdxs = []int32{}
@@ -180,11 +190,13 @@
 		return
 	}
 	File_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto = protoimpl.FileBuilder{
-		RawDescriptor:     xxx_File_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto_rawdesc,
+		RawDescriptor:     xxx_File_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto_rawDesc,
 		GoTypes:           xxx_File_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto_goTypes,
 		DependencyIndexes: xxx_File_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto_depIdxs,
+		FilesRegistry:     protoregistry.GlobalFiles,
+		TypesRegistry:     protoregistry.GlobalTypes,
 	}.Init()
-	proto.RegisterFile("github.com/golang/protobuf/protoc-gen-go/descriptor/descriptor.proto", xxx_File_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto_rawdesc_gzipped)
+	xxx_File_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto_rawDesc = nil
 	xxx_File_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto_goTypes = nil
 	xxx_File_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto_depIdxs = nil
 }
diff --git a/protoc-gen-go/plugin/plugin.pb.go b/protoc-gen-go/plugin/plugin.pb.go
index 7d13e68..60fdf29 100644
--- a/protoc-gen-go/plugin/plugin.pb.go
+++ b/protoc-gen-go/plugin/plugin.pb.go
@@ -4,12 +4,15 @@
 package plugin_go
 
 import (
-	proto "github.com/golang/protobuf/proto"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
+	protoregistry "github.com/golang/protobuf/v2/reflect/protoregistry"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 	plugin "github.com/golang/protobuf/v2/types/plugin"
+	sync "sync"
 )
 
+const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+
 // Symbols defined in public import of google/protobuf/compiler/plugin.proto
 
 type Version = plugin.Version
@@ -17,8 +20,9 @@
 type CodeGeneratorResponse = plugin.CodeGeneratorResponse
 type CodeGeneratorResponse_File = plugin.CodeGeneratorResponse_File
 
-var xxx_File_github_com_golang_protobuf_protoc_gen_go_plugin_plugin_proto_rawdesc = []byte{
-	// 172 bytes of the wire-encoded FileDescriptorProto
+var File_github_com_golang_protobuf_protoc_gen_go_plugin_plugin_proto protoreflect.FileDescriptor
+
+var xxx_File_github_com_golang_protobuf_protoc_gen_go_plugin_plugin_proto_rawDesc = []byte{
 	0x0a, 0x3c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x6c,
 	0x61, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x72, 0x6f,
 	0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x67, 0x6f, 0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69,
@@ -32,11 +36,17 @@
 	0x67, 0x6f, 0x50, 0x00, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32,
 }
 
-var xxx_File_github_com_golang_protobuf_protoc_gen_go_plugin_plugin_proto_rawdesc_gzipped = protoimpl.X.CompressGZIP(xxx_File_github_com_golang_protobuf_protoc_gen_go_plugin_plugin_proto_rawdesc)
+var (
+	xxx_File_github_com_golang_protobuf_protoc_gen_go_plugin_plugin_proto_rawDesc_once sync.Once
+	xxx_File_github_com_golang_protobuf_protoc_gen_go_plugin_plugin_proto_rawDesc_data = xxx_File_github_com_golang_protobuf_protoc_gen_go_plugin_plugin_proto_rawDesc
+)
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
-
-var File_github_com_golang_protobuf_protoc_gen_go_plugin_plugin_proto protoreflect.FileDescriptor
+func xxx_File_github_com_golang_protobuf_protoc_gen_go_plugin_plugin_proto_rawDescGZIP() []byte {
+	xxx_File_github_com_golang_protobuf_protoc_gen_go_plugin_plugin_proto_rawDesc_once.Do(func() {
+		xxx_File_github_com_golang_protobuf_protoc_gen_go_plugin_plugin_proto_rawDesc_data = protoimpl.X.CompressGZIP(xxx_File_github_com_golang_protobuf_protoc_gen_go_plugin_plugin_proto_rawDesc_data)
+	})
+	return xxx_File_github_com_golang_protobuf_protoc_gen_go_plugin_plugin_proto_rawDesc_data
+}
 
 var xxx_File_github_com_golang_protobuf_protoc_gen_go_plugin_plugin_proto_goTypes = []interface{}{}
 var xxx_File_github_com_golang_protobuf_protoc_gen_go_plugin_plugin_proto_depIdxs = []int32{}
@@ -47,11 +57,13 @@
 		return
 	}
 	File_github_com_golang_protobuf_protoc_gen_go_plugin_plugin_proto = protoimpl.FileBuilder{
-		RawDescriptor:     xxx_File_github_com_golang_protobuf_protoc_gen_go_plugin_plugin_proto_rawdesc,
+		RawDescriptor:     xxx_File_github_com_golang_protobuf_protoc_gen_go_plugin_plugin_proto_rawDesc,
 		GoTypes:           xxx_File_github_com_golang_protobuf_protoc_gen_go_plugin_plugin_proto_goTypes,
 		DependencyIndexes: xxx_File_github_com_golang_protobuf_protoc_gen_go_plugin_plugin_proto_depIdxs,
+		FilesRegistry:     protoregistry.GlobalFiles,
+		TypesRegistry:     protoregistry.GlobalTypes,
 	}.Init()
-	proto.RegisterFile("github.com/golang/protobuf/protoc-gen-go/plugin/plugin.proto", xxx_File_github_com_golang_protobuf_protoc_gen_go_plugin_plugin_proto_rawdesc_gzipped)
+	xxx_File_github_com_golang_protobuf_protoc_gen_go_plugin_plugin_proto_rawDesc = nil
 	xxx_File_github_com_golang_protobuf_protoc_gen_go_plugin_plugin_proto_goTypes = nil
 	xxx_File_github_com_golang_protobuf_protoc_gen_go_plugin_plugin_proto_depIdxs = nil
 }
diff --git a/ptypes/any/any.pb.go b/ptypes/any/any.pb.go
index 1857c74..4fee3bf 100644
--- a/ptypes/any/any.pb.go
+++ b/ptypes/any/any.pb.go
@@ -4,18 +4,22 @@
 package any
 
 import (
-	proto "github.com/golang/protobuf/proto"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
+	protoregistry "github.com/golang/protobuf/v2/reflect/protoregistry"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 	known "github.com/golang/protobuf/v2/types/known"
+	sync "sync"
 )
 
+const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+
 // Symbols defined in public import of google/protobuf/any.proto
 
 type Any = known.Any
 
-var xxx_File_github_com_golang_protobuf_ptypes_any_any_proto_rawdesc = []byte{
-	// 131 bytes of the wire-encoded FileDescriptorProto
+var File_github_com_golang_protobuf_ptypes_any_any_proto protoreflect.FileDescriptor
+
+var xxx_File_github_com_golang_protobuf_ptypes_any_any_proto_rawDesc = []byte{
 	0x0a, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x6c,
 	0x61, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x74, 0x79,
 	0x70, 0x65, 0x73, 0x2f, 0x61, 0x6e, 0x79, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74,
@@ -27,11 +31,17 @@
 	0x74, 0x6f, 0x33,
 }
 
-var xxx_File_github_com_golang_protobuf_ptypes_any_any_proto_rawdesc_gzipped = protoimpl.X.CompressGZIP(xxx_File_github_com_golang_protobuf_ptypes_any_any_proto_rawdesc)
+var (
+	xxx_File_github_com_golang_protobuf_ptypes_any_any_proto_rawDesc_once sync.Once
+	xxx_File_github_com_golang_protobuf_ptypes_any_any_proto_rawDesc_data = xxx_File_github_com_golang_protobuf_ptypes_any_any_proto_rawDesc
+)
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
-
-var File_github_com_golang_protobuf_ptypes_any_any_proto protoreflect.FileDescriptor
+func xxx_File_github_com_golang_protobuf_ptypes_any_any_proto_rawDescGZIP() []byte {
+	xxx_File_github_com_golang_protobuf_ptypes_any_any_proto_rawDesc_once.Do(func() {
+		xxx_File_github_com_golang_protobuf_ptypes_any_any_proto_rawDesc_data = protoimpl.X.CompressGZIP(xxx_File_github_com_golang_protobuf_ptypes_any_any_proto_rawDesc_data)
+	})
+	return xxx_File_github_com_golang_protobuf_ptypes_any_any_proto_rawDesc_data
+}
 
 var xxx_File_github_com_golang_protobuf_ptypes_any_any_proto_goTypes = []interface{}{}
 var xxx_File_github_com_golang_protobuf_ptypes_any_any_proto_depIdxs = []int32{}
@@ -42,11 +52,13 @@
 		return
 	}
 	File_github_com_golang_protobuf_ptypes_any_any_proto = protoimpl.FileBuilder{
-		RawDescriptor:     xxx_File_github_com_golang_protobuf_ptypes_any_any_proto_rawdesc,
+		RawDescriptor:     xxx_File_github_com_golang_protobuf_ptypes_any_any_proto_rawDesc,
 		GoTypes:           xxx_File_github_com_golang_protobuf_ptypes_any_any_proto_goTypes,
 		DependencyIndexes: xxx_File_github_com_golang_protobuf_ptypes_any_any_proto_depIdxs,
+		FilesRegistry:     protoregistry.GlobalFiles,
+		TypesRegistry:     protoregistry.GlobalTypes,
 	}.Init()
-	proto.RegisterFile("github.com/golang/protobuf/ptypes/any/any.proto", xxx_File_github_com_golang_protobuf_ptypes_any_any_proto_rawdesc_gzipped)
+	xxx_File_github_com_golang_protobuf_ptypes_any_any_proto_rawDesc = nil
 	xxx_File_github_com_golang_protobuf_ptypes_any_any_proto_goTypes = nil
 	xxx_File_github_com_golang_protobuf_ptypes_any_any_proto_depIdxs = nil
 }
diff --git a/ptypes/duration/duration.pb.go b/ptypes/duration/duration.pb.go
index af0e70b..b173a1d 100644
--- a/ptypes/duration/duration.pb.go
+++ b/ptypes/duration/duration.pb.go
@@ -4,18 +4,22 @@
 package duration
 
 import (
-	proto "github.com/golang/protobuf/proto"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
+	protoregistry "github.com/golang/protobuf/v2/reflect/protoregistry"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 	known "github.com/golang/protobuf/v2/types/known"
+	sync "sync"
 )
 
+const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+
 // Symbols defined in public import of google/protobuf/duration.proto
 
 type Duration = known.Duration
 
-var xxx_File_github_com_golang_protobuf_ptypes_duration_duration_proto_rawdesc = []byte{
-	// 156 bytes of the wire-encoded FileDescriptorProto
+var File_github_com_golang_protobuf_ptypes_duration_duration_proto protoreflect.FileDescriptor
+
+var xxx_File_github_com_golang_protobuf_ptypes_duration_duration_proto_rawDesc = []byte{
 	0x0a, 0x39, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x6c,
 	0x61, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x74, 0x79,
 	0x70, 0x65, 0x73, 0x2f, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x64, 0x75, 0x72,
@@ -28,11 +32,17 @@
 	0x6f, 0x6e, 0x50, 0x00, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
-var xxx_File_github_com_golang_protobuf_ptypes_duration_duration_proto_rawdesc_gzipped = protoimpl.X.CompressGZIP(xxx_File_github_com_golang_protobuf_ptypes_duration_duration_proto_rawdesc)
+var (
+	xxx_File_github_com_golang_protobuf_ptypes_duration_duration_proto_rawDesc_once sync.Once
+	xxx_File_github_com_golang_protobuf_ptypes_duration_duration_proto_rawDesc_data = xxx_File_github_com_golang_protobuf_ptypes_duration_duration_proto_rawDesc
+)
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
-
-var File_github_com_golang_protobuf_ptypes_duration_duration_proto protoreflect.FileDescriptor
+func xxx_File_github_com_golang_protobuf_ptypes_duration_duration_proto_rawDescGZIP() []byte {
+	xxx_File_github_com_golang_protobuf_ptypes_duration_duration_proto_rawDesc_once.Do(func() {
+		xxx_File_github_com_golang_protobuf_ptypes_duration_duration_proto_rawDesc_data = protoimpl.X.CompressGZIP(xxx_File_github_com_golang_protobuf_ptypes_duration_duration_proto_rawDesc_data)
+	})
+	return xxx_File_github_com_golang_protobuf_ptypes_duration_duration_proto_rawDesc_data
+}
 
 var xxx_File_github_com_golang_protobuf_ptypes_duration_duration_proto_goTypes = []interface{}{}
 var xxx_File_github_com_golang_protobuf_ptypes_duration_duration_proto_depIdxs = []int32{}
@@ -43,11 +53,13 @@
 		return
 	}
 	File_github_com_golang_protobuf_ptypes_duration_duration_proto = protoimpl.FileBuilder{
-		RawDescriptor:     xxx_File_github_com_golang_protobuf_ptypes_duration_duration_proto_rawdesc,
+		RawDescriptor:     xxx_File_github_com_golang_protobuf_ptypes_duration_duration_proto_rawDesc,
 		GoTypes:           xxx_File_github_com_golang_protobuf_ptypes_duration_duration_proto_goTypes,
 		DependencyIndexes: xxx_File_github_com_golang_protobuf_ptypes_duration_duration_proto_depIdxs,
+		FilesRegistry:     protoregistry.GlobalFiles,
+		TypesRegistry:     protoregistry.GlobalTypes,
 	}.Init()
-	proto.RegisterFile("github.com/golang/protobuf/ptypes/duration/duration.proto", xxx_File_github_com_golang_protobuf_ptypes_duration_duration_proto_rawdesc_gzipped)
+	xxx_File_github_com_golang_protobuf_ptypes_duration_duration_proto_rawDesc = nil
 	xxx_File_github_com_golang_protobuf_ptypes_duration_duration_proto_goTypes = nil
 	xxx_File_github_com_golang_protobuf_ptypes_duration_duration_proto_depIdxs = nil
 }
diff --git a/ptypes/empty/empty.pb.go b/ptypes/empty/empty.pb.go
index 726c360..a2fa06a 100644
--- a/ptypes/empty/empty.pb.go
+++ b/ptypes/empty/empty.pb.go
@@ -4,18 +4,22 @@
 package empty
 
 import (
-	proto "github.com/golang/protobuf/proto"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
+	protoregistry "github.com/golang/protobuf/v2/reflect/protoregistry"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 	known "github.com/golang/protobuf/v2/types/known"
+	sync "sync"
 )
 
+const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+
 // Symbols defined in public import of google/protobuf/empty.proto
 
 type Empty = known.Empty
 
-var xxx_File_github_com_golang_protobuf_ptypes_empty_empty_proto_rawdesc = []byte{
-	// 141 bytes of the wire-encoded FileDescriptorProto
+var File_github_com_golang_protobuf_ptypes_empty_empty_proto protoreflect.FileDescriptor
+
+var xxx_File_github_com_golang_protobuf_ptypes_empty_empty_proto_rawDesc = []byte{
 	0x0a, 0x33, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x6c,
 	0x61, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x74, 0x79,
 	0x70, 0x65, 0x73, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e,
@@ -27,11 +31,17 @@
 	0x70, 0x74, 0x79, 0x50, 0x00, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
-var xxx_File_github_com_golang_protobuf_ptypes_empty_empty_proto_rawdesc_gzipped = protoimpl.X.CompressGZIP(xxx_File_github_com_golang_protobuf_ptypes_empty_empty_proto_rawdesc)
+var (
+	xxx_File_github_com_golang_protobuf_ptypes_empty_empty_proto_rawDesc_once sync.Once
+	xxx_File_github_com_golang_protobuf_ptypes_empty_empty_proto_rawDesc_data = xxx_File_github_com_golang_protobuf_ptypes_empty_empty_proto_rawDesc
+)
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
-
-var File_github_com_golang_protobuf_ptypes_empty_empty_proto protoreflect.FileDescriptor
+func xxx_File_github_com_golang_protobuf_ptypes_empty_empty_proto_rawDescGZIP() []byte {
+	xxx_File_github_com_golang_protobuf_ptypes_empty_empty_proto_rawDesc_once.Do(func() {
+		xxx_File_github_com_golang_protobuf_ptypes_empty_empty_proto_rawDesc_data = protoimpl.X.CompressGZIP(xxx_File_github_com_golang_protobuf_ptypes_empty_empty_proto_rawDesc_data)
+	})
+	return xxx_File_github_com_golang_protobuf_ptypes_empty_empty_proto_rawDesc_data
+}
 
 var xxx_File_github_com_golang_protobuf_ptypes_empty_empty_proto_goTypes = []interface{}{}
 var xxx_File_github_com_golang_protobuf_ptypes_empty_empty_proto_depIdxs = []int32{}
@@ -42,11 +52,13 @@
 		return
 	}
 	File_github_com_golang_protobuf_ptypes_empty_empty_proto = protoimpl.FileBuilder{
-		RawDescriptor:     xxx_File_github_com_golang_protobuf_ptypes_empty_empty_proto_rawdesc,
+		RawDescriptor:     xxx_File_github_com_golang_protobuf_ptypes_empty_empty_proto_rawDesc,
 		GoTypes:           xxx_File_github_com_golang_protobuf_ptypes_empty_empty_proto_goTypes,
 		DependencyIndexes: xxx_File_github_com_golang_protobuf_ptypes_empty_empty_proto_depIdxs,
+		FilesRegistry:     protoregistry.GlobalFiles,
+		TypesRegistry:     protoregistry.GlobalTypes,
 	}.Init()
-	proto.RegisterFile("github.com/golang/protobuf/ptypes/empty/empty.proto", xxx_File_github_com_golang_protobuf_ptypes_empty_empty_proto_rawdesc_gzipped)
+	xxx_File_github_com_golang_protobuf_ptypes_empty_empty_proto_rawDesc = nil
 	xxx_File_github_com_golang_protobuf_ptypes_empty_empty_proto_goTypes = nil
 	xxx_File_github_com_golang_protobuf_ptypes_empty_empty_proto_depIdxs = nil
 }
diff --git a/ptypes/struct/struct.pb.go b/ptypes/struct/struct.pb.go
index 543a925..3f848ef 100644
--- a/ptypes/struct/struct.pb.go
+++ b/ptypes/struct/struct.pb.go
@@ -4,12 +4,15 @@
 package structpb
 
 import (
-	proto "github.com/golang/protobuf/proto"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
+	protoregistry "github.com/golang/protobuf/v2/reflect/protoregistry"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 	known "github.com/golang/protobuf/v2/types/known"
+	sync "sync"
 )
 
+const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+
 // Symbols defined in public import of google/protobuf/struct.proto
 
 type NullValue = known.NullValue
@@ -29,8 +32,9 @@
 type Value_ListValue = known.Value_ListValue
 type ListValue = known.ListValue
 
-var xxx_File_github_com_golang_protobuf_ptypes_struct_struct_proto_rawdesc = []byte{
-	// 148 bytes of the wire-encoded FileDescriptorProto
+var File_github_com_golang_protobuf_ptypes_struct_struct_proto protoreflect.FileDescriptor
+
+var xxx_File_github_com_golang_protobuf_ptypes_struct_struct_proto_rawDesc = []byte{
 	0x0a, 0x35, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x6c,
 	0x61, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x74, 0x79,
 	0x70, 0x65, 0x73, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63,
@@ -43,11 +47,17 @@
 	0x6f, 0x74, 0x6f, 0x33,
 }
 
-var xxx_File_github_com_golang_protobuf_ptypes_struct_struct_proto_rawdesc_gzipped = protoimpl.X.CompressGZIP(xxx_File_github_com_golang_protobuf_ptypes_struct_struct_proto_rawdesc)
+var (
+	xxx_File_github_com_golang_protobuf_ptypes_struct_struct_proto_rawDesc_once sync.Once
+	xxx_File_github_com_golang_protobuf_ptypes_struct_struct_proto_rawDesc_data = xxx_File_github_com_golang_protobuf_ptypes_struct_struct_proto_rawDesc
+)
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
-
-var File_github_com_golang_protobuf_ptypes_struct_struct_proto protoreflect.FileDescriptor
+func xxx_File_github_com_golang_protobuf_ptypes_struct_struct_proto_rawDescGZIP() []byte {
+	xxx_File_github_com_golang_protobuf_ptypes_struct_struct_proto_rawDesc_once.Do(func() {
+		xxx_File_github_com_golang_protobuf_ptypes_struct_struct_proto_rawDesc_data = protoimpl.X.CompressGZIP(xxx_File_github_com_golang_protobuf_ptypes_struct_struct_proto_rawDesc_data)
+	})
+	return xxx_File_github_com_golang_protobuf_ptypes_struct_struct_proto_rawDesc_data
+}
 
 var xxx_File_github_com_golang_protobuf_ptypes_struct_struct_proto_goTypes = []interface{}{}
 var xxx_File_github_com_golang_protobuf_ptypes_struct_struct_proto_depIdxs = []int32{}
@@ -58,11 +68,13 @@
 		return
 	}
 	File_github_com_golang_protobuf_ptypes_struct_struct_proto = protoimpl.FileBuilder{
-		RawDescriptor:     xxx_File_github_com_golang_protobuf_ptypes_struct_struct_proto_rawdesc,
+		RawDescriptor:     xxx_File_github_com_golang_protobuf_ptypes_struct_struct_proto_rawDesc,
 		GoTypes:           xxx_File_github_com_golang_protobuf_ptypes_struct_struct_proto_goTypes,
 		DependencyIndexes: xxx_File_github_com_golang_protobuf_ptypes_struct_struct_proto_depIdxs,
+		FilesRegistry:     protoregistry.GlobalFiles,
+		TypesRegistry:     protoregistry.GlobalTypes,
 	}.Init()
-	proto.RegisterFile("github.com/golang/protobuf/ptypes/struct/struct.proto", xxx_File_github_com_golang_protobuf_ptypes_struct_struct_proto_rawdesc_gzipped)
+	xxx_File_github_com_golang_protobuf_ptypes_struct_struct_proto_rawDesc = nil
 	xxx_File_github_com_golang_protobuf_ptypes_struct_struct_proto_goTypes = nil
 	xxx_File_github_com_golang_protobuf_ptypes_struct_struct_proto_depIdxs = nil
 }
diff --git a/ptypes/timestamp/timestamp.pb.go b/ptypes/timestamp/timestamp.pb.go
index c993c58..b4c4abe 100644
--- a/ptypes/timestamp/timestamp.pb.go
+++ b/ptypes/timestamp/timestamp.pb.go
@@ -4,18 +4,22 @@
 package timestamp
 
 import (
-	proto "github.com/golang/protobuf/proto"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
+	protoregistry "github.com/golang/protobuf/v2/reflect/protoregistry"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 	known "github.com/golang/protobuf/v2/types/known"
+	sync "sync"
 )
 
+const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+
 // Symbols defined in public import of google/protobuf/timestamp.proto
 
 type Timestamp = known.Timestamp
 
-var xxx_File_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto_rawdesc = []byte{
-	// 161 bytes of the wire-encoded FileDescriptorProto
+var File_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto protoreflect.FileDescriptor
+
+var xxx_File_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto_rawDesc = []byte{
 	0x0a, 0x3b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x6c,
 	0x61, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x74, 0x79,
 	0x70, 0x65, 0x73, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2f, 0x74, 0x69,
@@ -29,11 +33,17 @@
 	0x33,
 }
 
-var xxx_File_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto_rawdesc_gzipped = protoimpl.X.CompressGZIP(xxx_File_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto_rawdesc)
+var (
+	xxx_File_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto_rawDesc_once sync.Once
+	xxx_File_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto_rawDesc_data = xxx_File_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto_rawDesc
+)
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
-
-var File_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto protoreflect.FileDescriptor
+func xxx_File_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto_rawDescGZIP() []byte {
+	xxx_File_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto_rawDesc_once.Do(func() {
+		xxx_File_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto_rawDesc_data = protoimpl.X.CompressGZIP(xxx_File_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto_rawDesc_data)
+	})
+	return xxx_File_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto_rawDesc_data
+}
 
 var xxx_File_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto_goTypes = []interface{}{}
 var xxx_File_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto_depIdxs = []int32{}
@@ -44,11 +54,13 @@
 		return
 	}
 	File_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto = protoimpl.FileBuilder{
-		RawDescriptor:     xxx_File_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto_rawdesc,
+		RawDescriptor:     xxx_File_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto_rawDesc,
 		GoTypes:           xxx_File_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto_goTypes,
 		DependencyIndexes: xxx_File_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto_depIdxs,
+		FilesRegistry:     protoregistry.GlobalFiles,
+		TypesRegistry:     protoregistry.GlobalTypes,
 	}.Init()
-	proto.RegisterFile("github.com/golang/protobuf/ptypes/timestamp/timestamp.proto", xxx_File_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto_rawdesc_gzipped)
+	xxx_File_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto_rawDesc = nil
 	xxx_File_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto_goTypes = nil
 	xxx_File_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto_depIdxs = nil
 }
diff --git a/ptypes/timestamp_test.go b/ptypes/timestamp_test.go
index 179f503..9681118 100644
--- a/ptypes/timestamp_test.go
+++ b/ptypes/timestamp_test.go
@@ -97,7 +97,7 @@
 		// Not much testing needed because presumably time.Format is
 		// well-tested.
 		{&tspb.Timestamp{Seconds: 0, Nanos: 0}, "1970-01-01T00:00:00Z"},
-		{&tspb.Timestamp{Seconds: minValidSeconds - 1, Nanos: 0}, "(timestamp: seconds:-62135596801  before 0001-01-01)"},
+		{&tspb.Timestamp{Seconds: minValidSeconds - 1, Nanos: 0}, "(timestamp: seconds:-62135596801 before 0001-01-01)"},
 	} {
 		got := TimestampString(test.ts)
 		if got != test.want {
diff --git a/ptypes/wrappers/wrappers.pb.go b/ptypes/wrappers/wrappers.pb.go
index 7e47bc6..9c70983 100644
--- a/ptypes/wrappers/wrappers.pb.go
+++ b/ptypes/wrappers/wrappers.pb.go
@@ -4,12 +4,15 @@
 package wrappers
 
 import (
-	proto "github.com/golang/protobuf/proto"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
+	protoregistry "github.com/golang/protobuf/v2/reflect/protoregistry"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 	known "github.com/golang/protobuf/v2/types/known"
+	sync "sync"
 )
 
+const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
+
 // Symbols defined in public import of google/protobuf/wrappers.proto
 
 type DoubleValue = known.DoubleValue
@@ -22,8 +25,9 @@
 type StringValue = known.StringValue
 type BytesValue = known.BytesValue
 
-var xxx_File_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto_rawdesc = []byte{
-	// 156 bytes of the wire-encoded FileDescriptorProto
+var File_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto protoreflect.FileDescriptor
+
+var xxx_File_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto_rawDesc = []byte{
 	0x0a, 0x39, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x6c,
 	0x61, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x74, 0x79,
 	0x70, 0x65, 0x73, 0x2f, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x2f, 0x77, 0x72, 0x61,
@@ -36,11 +40,17 @@
 	0x72, 0x73, 0x50, 0x00, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
-var xxx_File_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto_rawdesc_gzipped = protoimpl.X.CompressGZIP(xxx_File_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto_rawdesc)
+var (
+	xxx_File_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto_rawDesc_once sync.Once
+	xxx_File_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto_rawDesc_data = xxx_File_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto_rawDesc
+)
 
-const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
-
-var File_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto protoreflect.FileDescriptor
+func xxx_File_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto_rawDescGZIP() []byte {
+	xxx_File_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto_rawDesc_once.Do(func() {
+		xxx_File_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto_rawDesc_data = protoimpl.X.CompressGZIP(xxx_File_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto_rawDesc_data)
+	})
+	return xxx_File_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto_rawDesc_data
+}
 
 var xxx_File_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto_goTypes = []interface{}{}
 var xxx_File_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto_depIdxs = []int32{}
@@ -51,11 +61,13 @@
 		return
 	}
 	File_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto = protoimpl.FileBuilder{
-		RawDescriptor:     xxx_File_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto_rawdesc,
+		RawDescriptor:     xxx_File_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto_rawDesc,
 		GoTypes:           xxx_File_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto_goTypes,
 		DependencyIndexes: xxx_File_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto_depIdxs,
+		FilesRegistry:     protoregistry.GlobalFiles,
+		TypesRegistry:     protoregistry.GlobalTypes,
 	}.Init()
-	proto.RegisterFile("github.com/golang/protobuf/ptypes/wrappers/wrappers.proto", xxx_File_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto_rawdesc_gzipped)
+	xxx_File_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto_rawDesc = nil
 	xxx_File_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto_goTypes = nil
 	xxx_File_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto_depIdxs = nil
 }