cmd/protoc-gen-go: use protoapi.CompressGZIP

Calling a helper function directly should reduce binary bloat slightly.

Change-Id: I6068dc4cd00c8d90d2e6e6d99633b81388bc8781
Reviewed-on: https://go-review.googlesource.com/c/164679
Reviewed-by: Damien Neil <dneil@google.com>
diff --git a/cmd/protoc-gen-go/internal_gengo/main.go b/cmd/protoc-gen-go/internal_gengo/main.go
index e842e6e..5357224 100644
--- a/cmd/protoc-gen-go/internal_gengo/main.go
+++ b/cmd/protoc-gen-go/internal_gengo/main.go
@@ -34,8 +34,6 @@
 const generatedCodeVersion = 3
 
 const (
-	bytesPackage    = protogen.GoImportPath("bytes")
-	gzipPackage     = protogen.GoImportPath("compress/gzip")
 	mathPackage     = protogen.GoImportPath("math")
 	protoPackage    = protogen.GoImportPath("github.com/golang/protobuf/proto")
 	protoapiPackage = protogen.GoImportPath("github.com/golang/protobuf/protoapi")
@@ -279,17 +277,9 @@
 	g.P("}")
 	g.P()
 
-	// TODO: Add a helper function in protoapi or protoimpl?
-	// This function would probably encode the input lazily upon first use.
-	// Currently, the GZIPed form is used eagerly in v1 registration.
-	// See https://play.golang.org/p/_atJHs0izTH
-	g.P("var ", f.descriptorGzipVar, " = func() []byte {")
-	g.P("bb := new(", bytesPackage.Ident("Buffer"), ")")
-	g.P("zw, _ := ", gzipPackage.Ident("NewWriterLevel"), "(bb, ", gzipPackage.Ident("NoCompression"), ")")
-	g.P("zw.Write(", f.descriptorRawVar, ")")
-	g.P("zw.Close()")
-	g.P("return bb.Bytes()")
-	g.P("}()")
+	// TODO: Modify CompressGZIP to lazy encode? Currently, the GZIP'd form
+	// is eagerly registered in v1, preventing any benefit from lazy encoding.
+	g.P("var ", f.descriptorGzipVar, " = ", protoapiPackage.Ident("CompressGZIP"), "(", f.descriptorRawVar, ")")
 	g.P()
 }
 
diff --git a/cmd/protoc-gen-go/testdata/annotations/annotations.pb.go b/cmd/protoc-gen-go/testdata/annotations/annotations.pb.go
index b5bc327..4044ee7 100644
--- a/cmd/protoc-gen-go/testdata/annotations/annotations.pb.go
+++ b/cmd/protoc-gen-go/testdata/annotations/annotations.pb.go
@@ -4,9 +4,8 @@
 package annotations
 
 import (
-	bytes "bytes"
-	gzip "compress/gzip"
 	proto "github.com/golang/protobuf/proto"
+	protoapi "github.com/golang/protobuf/protoapi"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 	reflect "reflect"
@@ -131,13 +130,7 @@
 	0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73,
 }
 
-var fileDescriptor_21dfaf6fd39fa3b7_gzipped = func() []byte {
-	bb := new(bytes.Buffer)
-	zw, _ := gzip.NewWriterLevel(bb, gzip.NoCompression)
-	zw.Write(fileDescriptor_21dfaf6fd39fa3b7)
-	zw.Close()
-	return bb.Bytes()
-}()
+var fileDescriptor_21dfaf6fd39fa3b7_gzipped = protoapi.CompressGZIP(fileDescriptor_21dfaf6fd39fa3b7)
 
 const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
 
diff --git a/cmd/protoc-gen-go/testdata/comments/comments.pb.go b/cmd/protoc-gen-go/testdata/comments/comments.pb.go
index 115866d..164fa39 100644
--- a/cmd/protoc-gen-go/testdata/comments/comments.pb.go
+++ b/cmd/protoc-gen-go/testdata/comments/comments.pb.go
@@ -6,9 +6,8 @@
 package comments
 
 import (
-	bytes "bytes"
-	gzip "compress/gzip"
 	proto "github.com/golang/protobuf/proto"
+	protoapi "github.com/golang/protobuf/protoapi"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 	reflect "reflect"
@@ -307,13 +306,7 @@
 	0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73,
 }
 
-var fileDescriptor_885e8293f1fab554_gzipped = func() []byte {
-	bb := new(bytes.Buffer)
-	zw, _ := gzip.NewWriterLevel(bb, gzip.NoCompression)
-	zw.Write(fileDescriptor_885e8293f1fab554)
-	zw.Close()
-	return bb.Bytes()
-}()
+var fileDescriptor_885e8293f1fab554_gzipped = protoapi.CompressGZIP(fileDescriptor_885e8293f1fab554)
 
 const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
 
diff --git a/cmd/protoc-gen-go/testdata/comments/deprecated.pb.go b/cmd/protoc-gen-go/testdata/comments/deprecated.pb.go
index 1169c3c..6a662d9 100644
--- a/cmd/protoc-gen-go/testdata/comments/deprecated.pb.go
+++ b/cmd/protoc-gen-go/testdata/comments/deprecated.pb.go
@@ -4,9 +4,8 @@
 package comments
 
 import (
-	bytes "bytes"
-	gzip "compress/gzip"
 	proto "github.com/golang/protobuf/proto"
+	protoapi "github.com/golang/protobuf/protoapi"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 	reflect "reflect"
@@ -116,13 +115,7 @@
 	0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
-var fileDescriptor_0336e614ee2de5f7_gzipped = func() []byte {
-	bb := new(bytes.Buffer)
-	zw, _ := gzip.NewWriterLevel(bb, gzip.NoCompression)
-	zw.Write(fileDescriptor_0336e614ee2de5f7)
-	zw.Close()
-	return bb.Bytes()
-}()
+var fileDescriptor_0336e614ee2de5f7_gzipped = protoapi.CompressGZIP(fileDescriptor_0336e614ee2de5f7)
 
 const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
 
diff --git a/cmd/protoc-gen-go/testdata/extensions/base/base.pb.go b/cmd/protoc-gen-go/testdata/extensions/base/base.pb.go
index f6f192a..2fa4f03 100644
--- a/cmd/protoc-gen-go/testdata/extensions/base/base.pb.go
+++ b/cmd/protoc-gen-go/testdata/extensions/base/base.pb.go
@@ -4,9 +4,8 @@
 package base
 
 import (
-	bytes "bytes"
-	gzip "compress/gzip"
 	proto "github.com/golang/protobuf/proto"
+	protoapi "github.com/golang/protobuf/protoapi"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 	reflect "reflect"
@@ -138,13 +137,7 @@
 	0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x62, 0x61, 0x73, 0x65,
 }
 
-var fileDescriptor_aebb28f8d5a04466_gzipped = func() []byte {
-	bb := new(bytes.Buffer)
-	zw, _ := gzip.NewWriterLevel(bb, gzip.NoCompression)
-	zw.Write(fileDescriptor_aebb28f8d5a04466)
-	zw.Close()
-	return bb.Bytes()
-}()
+var fileDescriptor_aebb28f8d5a04466_gzipped = protoapi.CompressGZIP(fileDescriptor_aebb28f8d5a04466)
 
 const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
 
diff --git a/cmd/protoc-gen-go/testdata/extensions/ext/ext.pb.go b/cmd/protoc-gen-go/testdata/extensions/ext/ext.pb.go
index 64cc3d2..a8f9c0d 100644
--- a/cmd/protoc-gen-go/testdata/extensions/ext/ext.pb.go
+++ b/cmd/protoc-gen-go/testdata/extensions/ext/ext.pb.go
@@ -4,9 +4,8 @@
 package ext
 
 import (
-	bytes "bytes"
-	gzip "compress/gzip"
 	proto "github.com/golang/protobuf/proto"
+	protoapi "github.com/golang/protobuf/protoapi"
 	base "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/extensions/base"
 	extra "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/extensions/extra"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
@@ -1146,13 +1145,7 @@
 	0x2f, 0x65, 0x78, 0x74,
 }
 
-var fileDescriptor_bf470ef4907b23cb_gzipped = func() []byte {
-	bb := new(bytes.Buffer)
-	zw, _ := gzip.NewWriterLevel(bb, gzip.NoCompression)
-	zw.Write(fileDescriptor_bf470ef4907b23cb)
-	zw.Close()
-	return bb.Bytes()
-}()
+var fileDescriptor_bf470ef4907b23cb_gzipped = protoapi.CompressGZIP(fileDescriptor_bf470ef4907b23cb)
 
 const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
 
diff --git a/cmd/protoc-gen-go/testdata/extensions/extra/extra.pb.go b/cmd/protoc-gen-go/testdata/extensions/extra/extra.pb.go
index 239dcfa..8394cc6 100644
--- a/cmd/protoc-gen-go/testdata/extensions/extra/extra.pb.go
+++ b/cmd/protoc-gen-go/testdata/extensions/extra/extra.pb.go
@@ -4,9 +4,8 @@
 package extra
 
 import (
-	bytes "bytes"
-	gzip "compress/gzip"
 	proto "github.com/golang/protobuf/proto"
+	protoapi "github.com/golang/protobuf/protoapi"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 	reflect "reflect"
@@ -80,13 +79,7 @@
 	0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x65, 0x78, 0x74, 0x72, 0x61,
 }
 
-var fileDescriptor_496c2a5e9c1e8739_gzipped = func() []byte {
-	bb := new(bytes.Buffer)
-	zw, _ := gzip.NewWriterLevel(bb, gzip.NoCompression)
-	zw.Write(fileDescriptor_496c2a5e9c1e8739)
-	zw.Close()
-	return bb.Bytes()
-}()
+var fileDescriptor_496c2a5e9c1e8739_gzipped = protoapi.CompressGZIP(fileDescriptor_496c2a5e9c1e8739)
 
 const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
 
diff --git a/cmd/protoc-gen-go/testdata/extensions/proto3/ext3.pb.go b/cmd/protoc-gen-go/testdata/extensions/proto3/ext3.pb.go
index 3af3513..8a66c05 100644
--- a/cmd/protoc-gen-go/testdata/extensions/proto3/ext3.pb.go
+++ b/cmd/protoc-gen-go/testdata/extensions/proto3/ext3.pb.go
@@ -4,9 +4,8 @@
 package proto3
 
 import (
-	bytes "bytes"
-	gzip "compress/gzip"
 	proto "github.com/golang/protobuf/proto"
+	protoapi "github.com/golang/protobuf/protoapi"
 	descriptor "github.com/golang/protobuf/protoc-gen-go/descriptor"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
@@ -637,13 +636,7 @@
 	0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
-var fileDescriptor_3db31bb248c8865e_gzipped = func() []byte {
-	bb := new(bytes.Buffer)
-	zw, _ := gzip.NewWriterLevel(bb, gzip.NoCompression)
-	zw.Write(fileDescriptor_3db31bb248c8865e)
-	zw.Close()
-	return bb.Bytes()
-}()
+var fileDescriptor_3db31bb248c8865e_gzipped = protoapi.CompressGZIP(fileDescriptor_3db31bb248c8865e)
 
 const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
 
diff --git a/cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go b/cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go
index aef8ce0..152119c 100644
--- a/cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go
+++ b/cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go
@@ -4,9 +4,8 @@
 package fieldnames
 
 import (
-	bytes "bytes"
-	gzip "compress/gzip"
 	proto "github.com/golang/protobuf/proto"
+	protoapi "github.com/golang/protobuf/protoapi"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 	reflect "reflect"
@@ -380,13 +379,7 @@
 	0x66, 0x69, 0x65, 0x6c, 0x64, 0x6e, 0x61, 0x6d, 0x65, 0x73,
 }
 
-var fileDescriptor_6bbe3f70febb9403_gzipped = func() []byte {
-	bb := new(bytes.Buffer)
-	zw, _ := gzip.NewWriterLevel(bb, gzip.NoCompression)
-	zw.Write(fileDescriptor_6bbe3f70febb9403)
-	zw.Close()
-	return bb.Bytes()
-}()
+var fileDescriptor_6bbe3f70febb9403_gzipped = protoapi.CompressGZIP(fileDescriptor_6bbe3f70febb9403)
 
 const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
 
diff --git a/cmd/protoc-gen-go/testdata/import_public/a.pb.go b/cmd/protoc-gen-go/testdata/import_public/a.pb.go
index 88c2a76..46a7c2b 100644
--- a/cmd/protoc-gen-go/testdata/import_public/a.pb.go
+++ b/cmd/protoc-gen-go/testdata/import_public/a.pb.go
@@ -4,9 +4,8 @@
 package import_public
 
 import (
-	bytes "bytes"
-	gzip "compress/gzip"
 	proto "github.com/golang/protobuf/proto"
+	protoapi "github.com/golang/protobuf/protoapi"
 	sub "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/import_public/sub"
 	sub2 "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/import_public/sub2"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
@@ -153,13 +152,7 @@
 	0x72, 0x74, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x50, 0x00, 0x50, 0x01, 0x50, 0x02,
 }
 
-var fileDescriptor_73b7577c95fa6b70_gzipped = func() []byte {
-	bb := new(bytes.Buffer)
-	zw, _ := gzip.NewWriterLevel(bb, gzip.NoCompression)
-	zw.Write(fileDescriptor_73b7577c95fa6b70)
-	zw.Close()
-	return bb.Bytes()
-}()
+var fileDescriptor_73b7577c95fa6b70_gzipped = protoapi.CompressGZIP(fileDescriptor_73b7577c95fa6b70)
 
 const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
 
diff --git a/cmd/protoc-gen-go/testdata/import_public/b.pb.go b/cmd/protoc-gen-go/testdata/import_public/b.pb.go
index ce1027a..6664f12 100644
--- a/cmd/protoc-gen-go/testdata/import_public/b.pb.go
+++ b/cmd/protoc-gen-go/testdata/import_public/b.pb.go
@@ -4,9 +4,8 @@
 package import_public
 
 import (
-	bytes "bytes"
-	gzip "compress/gzip"
 	proto "github.com/golang/protobuf/proto"
+	protoapi "github.com/golang/protobuf/protoapi"
 	sub "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/import_public/sub"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
@@ -95,13 +94,7 @@
 	0x72, 0x74, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63,
 }
 
-var fileDescriptor_84995586b3d09710_gzipped = func() []byte {
-	bb := new(bytes.Buffer)
-	zw, _ := gzip.NewWriterLevel(bb, gzip.NoCompression)
-	zw.Write(fileDescriptor_84995586b3d09710)
-	zw.Close()
-	return bb.Bytes()
-}()
+var fileDescriptor_84995586b3d09710_gzipped = protoapi.CompressGZIP(fileDescriptor_84995586b3d09710)
 
 const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
 
diff --git a/cmd/protoc-gen-go/testdata/import_public/sub/a.pb.go b/cmd/protoc-gen-go/testdata/import_public/sub/a.pb.go
index 981bf90..40daaa9 100644
--- a/cmd/protoc-gen-go/testdata/import_public/sub/a.pb.go
+++ b/cmd/protoc-gen-go/testdata/import_public/sub/a.pb.go
@@ -4,9 +4,8 @@
 package sub
 
 import (
-	bytes "bytes"
-	gzip "compress/gzip"
 	proto "github.com/golang/protobuf/proto"
+	protoapi "github.com/golang/protobuf/protoapi"
 	sub2 "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/import_public/sub2"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
@@ -438,13 +437,7 @@
 	0x62, 0x6c, 0x69, 0x63, 0x2f, 0x73, 0x75, 0x62, 0x50, 0x01,
 }
 
-var fileDescriptor_382f7805394b5c4e_gzipped = func() []byte {
-	bb := new(bytes.Buffer)
-	zw, _ := gzip.NewWriterLevel(bb, gzip.NoCompression)
-	zw.Write(fileDescriptor_382f7805394b5c4e)
-	zw.Close()
-	return bb.Bytes()
-}()
+var fileDescriptor_382f7805394b5c4e_gzipped = protoapi.CompressGZIP(fileDescriptor_382f7805394b5c4e)
 
 const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
 
diff --git a/cmd/protoc-gen-go/testdata/import_public/sub/b.pb.go b/cmd/protoc-gen-go/testdata/import_public/sub/b.pb.go
index 7a00609..5c375e0 100644
--- a/cmd/protoc-gen-go/testdata/import_public/sub/b.pb.go
+++ b/cmd/protoc-gen-go/testdata/import_public/sub/b.pb.go
@@ -4,9 +4,8 @@
 package sub
 
 import (
-	bytes "bytes"
-	gzip "compress/gzip"
 	proto "github.com/golang/protobuf/proto"
+	protoapi "github.com/golang/protobuf/protoapi"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 	reflect "reflect"
@@ -71,13 +70,7 @@
 	0x62,
 }
 
-var fileDescriptor_fc66afda3d7c2232_gzipped = func() []byte {
-	bb := new(bytes.Buffer)
-	zw, _ := gzip.NewWriterLevel(bb, gzip.NoCompression)
-	zw.Write(fileDescriptor_fc66afda3d7c2232)
-	zw.Close()
-	return bb.Bytes()
-}()
+var fileDescriptor_fc66afda3d7c2232_gzipped = protoapi.CompressGZIP(fileDescriptor_fc66afda3d7c2232)
 
 const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
 
diff --git a/cmd/protoc-gen-go/testdata/import_public/sub2/a.pb.go b/cmd/protoc-gen-go/testdata/import_public/sub2/a.pb.go
index bd2e822..ae05e82 100644
--- a/cmd/protoc-gen-go/testdata/import_public/sub2/a.pb.go
+++ b/cmd/protoc-gen-go/testdata/import_public/sub2/a.pb.go
@@ -4,9 +4,8 @@
 package sub2
 
 import (
-	bytes "bytes"
-	gzip "compress/gzip"
 	proto "github.com/golang/protobuf/proto"
+	protoapi "github.com/golang/protobuf/protoapi"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 	reflect "reflect"
@@ -71,13 +70,7 @@
 	0x74, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x2f, 0x73, 0x75, 0x62, 0x32,
 }
 
-var fileDescriptor_7ac53d99328778ac_gzipped = func() []byte {
-	bb := new(bytes.Buffer)
-	zw, _ := gzip.NewWriterLevel(bb, gzip.NoCompression)
-	zw.Write(fileDescriptor_7ac53d99328778ac)
-	zw.Close()
-	return bb.Bytes()
-}()
+var fileDescriptor_7ac53d99328778ac_gzipped = protoapi.CompressGZIP(fileDescriptor_7ac53d99328778ac)
 
 const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
 
diff --git a/cmd/protoc-gen-go/testdata/imports/fmt/m.pb.go b/cmd/protoc-gen-go/testdata/imports/fmt/m.pb.go
index 62b60ae..184c375 100644
--- a/cmd/protoc-gen-go/testdata/imports/fmt/m.pb.go
+++ b/cmd/protoc-gen-go/testdata/imports/fmt/m.pb.go
@@ -4,9 +4,8 @@
 package fmt
 
 import (
-	bytes "bytes"
-	gzip "compress/gzip"
 	proto "github.com/golang/protobuf/proto"
+	protoapi "github.com/golang/protobuf/protoapi"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 	reflect "reflect"
@@ -68,13 +67,7 @@
 	0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
-var fileDescriptor_72c126fcd452e392_gzipped = func() []byte {
-	bb := new(bytes.Buffer)
-	zw, _ := gzip.NewWriterLevel(bb, gzip.NoCompression)
-	zw.Write(fileDescriptor_72c126fcd452e392)
-	zw.Close()
-	return bb.Bytes()
-}()
+var fileDescriptor_72c126fcd452e392_gzipped = protoapi.CompressGZIP(fileDescriptor_72c126fcd452e392)
 
 const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
 
diff --git a/cmd/protoc-gen-go/testdata/imports/test_a_1/m1.pb.go b/cmd/protoc-gen-go/testdata/imports/test_a_1/m1.pb.go
index bdab9b3..a8e7e93 100644
--- a/cmd/protoc-gen-go/testdata/imports/test_a_1/m1.pb.go
+++ b/cmd/protoc-gen-go/testdata/imports/test_a_1/m1.pb.go
@@ -4,9 +4,8 @@
 package test_a_1
 
 import (
-	bytes "bytes"
-	gzip "compress/gzip"
 	proto "github.com/golang/protobuf/proto"
+	protoapi "github.com/golang/protobuf/protoapi"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 	reflect "reflect"
@@ -145,13 +144,7 @@
 	0x73, 0x74, 0x5f, 0x61, 0x5f, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
-var fileDescriptor_c1091de3fa870a14_gzipped = func() []byte {
-	bb := new(bytes.Buffer)
-	zw, _ := gzip.NewWriterLevel(bb, gzip.NoCompression)
-	zw.Write(fileDescriptor_c1091de3fa870a14)
-	zw.Close()
-	return bb.Bytes()
-}()
+var fileDescriptor_c1091de3fa870a14_gzipped = protoapi.CompressGZIP(fileDescriptor_c1091de3fa870a14)
 
 const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
 
diff --git a/cmd/protoc-gen-go/testdata/imports/test_a_1/m2.pb.go b/cmd/protoc-gen-go/testdata/imports/test_a_1/m2.pb.go
index e71523e..318bffa 100644
--- a/cmd/protoc-gen-go/testdata/imports/test_a_1/m2.pb.go
+++ b/cmd/protoc-gen-go/testdata/imports/test_a_1/m2.pb.go
@@ -4,9 +4,8 @@
 package test_a_1
 
 import (
-	bytes "bytes"
-	gzip "compress/gzip"
 	proto "github.com/golang/protobuf/proto"
+	protoapi "github.com/golang/protobuf/protoapi"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 	reflect "reflect"
@@ -69,13 +68,7 @@
 	0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
-var fileDescriptor_20cf27515c0d621c_gzipped = func() []byte {
-	bb := new(bytes.Buffer)
-	zw, _ := gzip.NewWriterLevel(bb, gzip.NoCompression)
-	zw.Write(fileDescriptor_20cf27515c0d621c)
-	zw.Close()
-	return bb.Bytes()
-}()
+var fileDescriptor_20cf27515c0d621c_gzipped = protoapi.CompressGZIP(fileDescriptor_20cf27515c0d621c)
 
 const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
 
diff --git a/cmd/protoc-gen-go/testdata/imports/test_a_2/m3.pb.go b/cmd/protoc-gen-go/testdata/imports/test_a_2/m3.pb.go
index 7280b96..bedc1b3 100644
--- a/cmd/protoc-gen-go/testdata/imports/test_a_2/m3.pb.go
+++ b/cmd/protoc-gen-go/testdata/imports/test_a_2/m3.pb.go
@@ -4,9 +4,8 @@
 package test_a_2
 
 import (
-	bytes "bytes"
-	gzip "compress/gzip"
 	proto "github.com/golang/protobuf/proto"
+	protoapi "github.com/golang/protobuf/protoapi"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 	reflect "reflect"
@@ -69,13 +68,7 @@
 	0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
-var fileDescriptor_ff9d8f834875c9c5_gzipped = func() []byte {
-	bb := new(bytes.Buffer)
-	zw, _ := gzip.NewWriterLevel(bb, gzip.NoCompression)
-	zw.Write(fileDescriptor_ff9d8f834875c9c5)
-	zw.Close()
-	return bb.Bytes()
-}()
+var fileDescriptor_ff9d8f834875c9c5_gzipped = protoapi.CompressGZIP(fileDescriptor_ff9d8f834875c9c5)
 
 const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
 
diff --git a/cmd/protoc-gen-go/testdata/imports/test_a_2/m4.pb.go b/cmd/protoc-gen-go/testdata/imports/test_a_2/m4.pb.go
index 6c7a8c0..56078f0 100644
--- a/cmd/protoc-gen-go/testdata/imports/test_a_2/m4.pb.go
+++ b/cmd/protoc-gen-go/testdata/imports/test_a_2/m4.pb.go
@@ -4,9 +4,8 @@
 package test_a_2
 
 import (
-	bytes "bytes"
-	gzip "compress/gzip"
 	proto "github.com/golang/protobuf/proto"
+	protoapi "github.com/golang/protobuf/protoapi"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 	reflect "reflect"
@@ -69,13 +68,7 @@
 	0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
-var fileDescriptor_fdd24f82f6c5a786_gzipped = func() []byte {
-	bb := new(bytes.Buffer)
-	zw, _ := gzip.NewWriterLevel(bb, gzip.NoCompression)
-	zw.Write(fileDescriptor_fdd24f82f6c5a786)
-	zw.Close()
-	return bb.Bytes()
-}()
+var fileDescriptor_fdd24f82f6c5a786_gzipped = protoapi.CompressGZIP(fileDescriptor_fdd24f82f6c5a786)
 
 const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
 
diff --git a/cmd/protoc-gen-go/testdata/imports/test_b_1/m1.pb.go b/cmd/protoc-gen-go/testdata/imports/test_b_1/m1.pb.go
index 8237a77..24d0065 100644
--- a/cmd/protoc-gen-go/testdata/imports/test_b_1/m1.pb.go
+++ b/cmd/protoc-gen-go/testdata/imports/test_b_1/m1.pb.go
@@ -4,9 +4,8 @@
 package beta
 
 import (
-	bytes "bytes"
-	gzip "compress/gzip"
 	proto "github.com/golang/protobuf/proto"
+	protoapi "github.com/golang/protobuf/protoapi"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 	reflect "reflect"
@@ -70,13 +69,7 @@
 	0x6f, 0x33,
 }
 
-var fileDescriptor_7f49573d035512a8_gzipped = func() []byte {
-	bb := new(bytes.Buffer)
-	zw, _ := gzip.NewWriterLevel(bb, gzip.NoCompression)
-	zw.Write(fileDescriptor_7f49573d035512a8)
-	zw.Close()
-	return bb.Bytes()
-}()
+var fileDescriptor_7f49573d035512a8_gzipped = protoapi.CompressGZIP(fileDescriptor_7f49573d035512a8)
 
 const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
 
diff --git a/cmd/protoc-gen-go/testdata/imports/test_b_1/m2.pb.go b/cmd/protoc-gen-go/testdata/imports/test_b_1/m2.pb.go
index ddf57b1..82cc175 100644
--- a/cmd/protoc-gen-go/testdata/imports/test_b_1/m2.pb.go
+++ b/cmd/protoc-gen-go/testdata/imports/test_b_1/m2.pb.go
@@ -4,9 +4,8 @@
 package beta
 
 import (
-	bytes "bytes"
-	gzip "compress/gzip"
 	proto "github.com/golang/protobuf/proto"
+	protoapi "github.com/golang/protobuf/protoapi"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 	reflect "reflect"
@@ -70,13 +69,7 @@
 	0x6f, 0x33,
 }
 
-var fileDescriptor_a1becddceeb586f2_gzipped = func() []byte {
-	bb := new(bytes.Buffer)
-	zw, _ := gzip.NewWriterLevel(bb, gzip.NoCompression)
-	zw.Write(fileDescriptor_a1becddceeb586f2)
-	zw.Close()
-	return bb.Bytes()
-}()
+var fileDescriptor_a1becddceeb586f2_gzipped = protoapi.CompressGZIP(fileDescriptor_a1becddceeb586f2)
 
 const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
 
diff --git a/cmd/protoc-gen-go/testdata/imports/test_import_a1m1.pb.go b/cmd/protoc-gen-go/testdata/imports/test_import_a1m1.pb.go
index 84ed62d..0a18af3 100644
--- a/cmd/protoc-gen-go/testdata/imports/test_import_a1m1.pb.go
+++ b/cmd/protoc-gen-go/testdata/imports/test_import_a1m1.pb.go
@@ -4,9 +4,8 @@
 package imports
 
 import (
-	bytes "bytes"
-	gzip "compress/gzip"
 	proto "github.com/golang/protobuf/proto"
+	protoapi "github.com/golang/protobuf/protoapi"
 	test_a_1 "github.com/golang/protobuf/protoc-gen-go/testdata/imports/test_a_1"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
@@ -81,13 +80,7 @@
 	0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
-var fileDescriptor_3b904a47327455f3_gzipped = func() []byte {
-	bb := new(bytes.Buffer)
-	zw, _ := gzip.NewWriterLevel(bb, gzip.NoCompression)
-	zw.Write(fileDescriptor_3b904a47327455f3)
-	zw.Close()
-	return bb.Bytes()
-}()
+var fileDescriptor_3b904a47327455f3_gzipped = protoapi.CompressGZIP(fileDescriptor_3b904a47327455f3)
 
 const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
 
diff --git a/cmd/protoc-gen-go/testdata/imports/test_import_a1m2.pb.go b/cmd/protoc-gen-go/testdata/imports/test_import_a1m2.pb.go
index 162ffe5..194ebed 100644
--- a/cmd/protoc-gen-go/testdata/imports/test_import_a1m2.pb.go
+++ b/cmd/protoc-gen-go/testdata/imports/test_import_a1m2.pb.go
@@ -4,9 +4,8 @@
 package imports
 
 import (
-	bytes "bytes"
-	gzip "compress/gzip"
 	proto "github.com/golang/protobuf/proto"
+	protoapi "github.com/golang/protobuf/protoapi"
 	test_a_1 "github.com/golang/protobuf/protoc-gen-go/testdata/imports/test_a_1"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
@@ -81,13 +80,7 @@
 	0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
-var fileDescriptor_bdb27b114687957d_gzipped = func() []byte {
-	bb := new(bytes.Buffer)
-	zw, _ := gzip.NewWriterLevel(bb, gzip.NoCompression)
-	zw.Write(fileDescriptor_bdb27b114687957d)
-	zw.Close()
-	return bb.Bytes()
-}()
+var fileDescriptor_bdb27b114687957d_gzipped = protoapi.CompressGZIP(fileDescriptor_bdb27b114687957d)
 
 const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
 
diff --git a/cmd/protoc-gen-go/testdata/imports/test_import_all.pb.go b/cmd/protoc-gen-go/testdata/imports/test_import_all.pb.go
index 2329baf..5f1e9e4 100644
--- a/cmd/protoc-gen-go/testdata/imports/test_import_all.pb.go
+++ b/cmd/protoc-gen-go/testdata/imports/test_import_all.pb.go
@@ -4,9 +4,8 @@
 package imports
 
 import (
-	bytes "bytes"
-	gzip "compress/gzip"
 	proto "github.com/golang/protobuf/proto"
+	protoapi "github.com/golang/protobuf/protoapi"
 	fmt "github.com/golang/protobuf/protoc-gen-go/testdata/imports/fmt"
 	test_a_1 "github.com/golang/protobuf/protoc-gen-go/testdata/imports/test_a_1"
 	_ "github.com/golang/protobuf/protoc-gen-go/testdata/imports/test_a_2"
@@ -134,13 +133,7 @@
 	0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
-var fileDescriptor_324466f0afc16f77_gzipped = func() []byte {
-	bb := new(bytes.Buffer)
-	zw, _ := gzip.NewWriterLevel(bb, gzip.NoCompression)
-	zw.Write(fileDescriptor_324466f0afc16f77)
-	zw.Close()
-	return bb.Bytes()
-}()
+var fileDescriptor_324466f0afc16f77_gzipped = protoapi.CompressGZIP(fileDescriptor_324466f0afc16f77)
 
 const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
 
diff --git a/cmd/protoc-gen-go/testdata/issue780_oneof_conflict/test.pb.go b/cmd/protoc-gen-go/testdata/issue780_oneof_conflict/test.pb.go
index 3ece6d1..79572fa 100644
--- a/cmd/protoc-gen-go/testdata/issue780_oneof_conflict/test.pb.go
+++ b/cmd/protoc-gen-go/testdata/issue780_oneof_conflict/test.pb.go
@@ -4,9 +4,8 @@
 package oneoftest
 
 import (
-	bytes "bytes"
-	gzip "compress/gzip"
 	proto "github.com/golang/protobuf/proto"
+	protoapi "github.com/golang/protobuf/protoapi"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 	reflect "reflect"
@@ -101,13 +100,7 @@
 	0x72, 0x42, 0x05, 0x0a, 0x03, 0x62, 0x61, 0x72,
 }
 
-var fileDescriptor_48462cafc802a68e_gzipped = func() []byte {
-	bb := new(bytes.Buffer)
-	zw, _ := gzip.NewWriterLevel(bb, gzip.NoCompression)
-	zw.Write(fileDescriptor_48462cafc802a68e)
-	zw.Close()
-	return bb.Bytes()
-}()
+var fileDescriptor_48462cafc802a68e_gzipped = protoapi.CompressGZIP(fileDescriptor_48462cafc802a68e)
 
 const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
 
diff --git a/cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go b/cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go
index 6cfd525..504be4b 100644
--- a/cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go
+++ b/cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go
@@ -4,9 +4,8 @@
 package nopackage
 
 import (
-	bytes "bytes"
-	gzip "compress/gzip"
 	proto "github.com/golang/protobuf/proto"
+	protoapi "github.com/golang/protobuf/protoapi"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 	reflect "reflect"
@@ -133,13 +132,7 @@
 	0x04, 0x5a, 0x45, 0x52, 0x4f, 0x10, 0x00,
 }
 
-var fileDescriptor_f33a1d5d178c43c9_gzipped = func() []byte {
-	bb := new(bytes.Buffer)
-	zw, _ := gzip.NewWriterLevel(bb, gzip.NoCompression)
-	zw.Write(fileDescriptor_f33a1d5d178c43c9)
-	zw.Close()
-	return bb.Bytes()
-}()
+var fileDescriptor_f33a1d5d178c43c9_gzipped = protoapi.CompressGZIP(fileDescriptor_f33a1d5d178c43c9)
 
 const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
 
diff --git a/cmd/protoc-gen-go/testdata/proto2/enum.pb.go b/cmd/protoc-gen-go/testdata/proto2/enum.pb.go
index 02e8d3f..50a943d 100644
--- a/cmd/protoc-gen-go/testdata/proto2/enum.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto2/enum.pb.go
@@ -4,9 +4,8 @@
 package proto2
 
 import (
-	bytes "bytes"
-	gzip "compress/gzip"
 	proto "github.com/golang/protobuf/proto"
+	protoapi "github.com/golang/protobuf/protoapi"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 	reflect "reflect"
@@ -441,13 +440,7 @@
 	0x2f, 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32,
 }
 
-var fileDescriptor_de9f68860d540858_gzipped = func() []byte {
-	bb := new(bytes.Buffer)
-	zw, _ := gzip.NewWriterLevel(bb, gzip.NoCompression)
-	zw.Write(fileDescriptor_de9f68860d540858)
-	zw.Close()
-	return bb.Bytes()
-}()
+var fileDescriptor_de9f68860d540858_gzipped = protoapi.CompressGZIP(fileDescriptor_de9f68860d540858)
 
 const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
 
diff --git a/cmd/protoc-gen-go/testdata/proto2/fields.pb.go b/cmd/protoc-gen-go/testdata/proto2/fields.pb.go
index f381fc2..1bc1330 100644
--- a/cmd/protoc-gen-go/testdata/proto2/fields.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto2/fields.pb.go
@@ -4,9 +4,8 @@
 package proto2
 
 import (
-	bytes "bytes"
-	gzip "compress/gzip"
 	proto "github.com/golang/protobuf/proto"
+	protoapi "github.com/golang/protobuf/protoapi"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 	math "math"
@@ -1713,13 +1712,7 @@
 	0x74, 0x61, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32,
 }
 
-var fileDescriptor_fd8a9d72b841fd68_gzipped = func() []byte {
-	bb := new(bytes.Buffer)
-	zw, _ := gzip.NewWriterLevel(bb, gzip.NoCompression)
-	zw.Write(fileDescriptor_fd8a9d72b841fd68)
-	zw.Close()
-	return bb.Bytes()
-}()
+var fileDescriptor_fd8a9d72b841fd68_gzipped = protoapi.CompressGZIP(fileDescriptor_fd8a9d72b841fd68)
 
 const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
 
diff --git a/cmd/protoc-gen-go/testdata/proto2/nested_messages.pb.go b/cmd/protoc-gen-go/testdata/proto2/nested_messages.pb.go
index 5c531f6..9f170cd 100644
--- a/cmd/protoc-gen-go/testdata/proto2/nested_messages.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto2/nested_messages.pb.go
@@ -4,9 +4,8 @@
 package proto2
 
 import (
-	bytes "bytes"
-	gzip "compress/gzip"
 	proto "github.com/golang/protobuf/proto"
+	protoapi "github.com/golang/protobuf/protoapi"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 	reflect "reflect"
@@ -176,13 +175,7 @@
 	0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32,
 }
 
-var fileDescriptor_7417ee157699d191_gzipped = func() []byte {
-	bb := new(bytes.Buffer)
-	zw, _ := gzip.NewWriterLevel(bb, gzip.NoCompression)
-	zw.Write(fileDescriptor_7417ee157699d191)
-	zw.Close()
-	return bb.Bytes()
-}()
+var fileDescriptor_7417ee157699d191_gzipped = protoapi.CompressGZIP(fileDescriptor_7417ee157699d191)
 
 const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
 
diff --git a/cmd/protoc-gen-go/testdata/proto2/proto2.pb.go b/cmd/protoc-gen-go/testdata/proto2/proto2.pb.go
index 5432599..3f52ab4 100644
--- a/cmd/protoc-gen-go/testdata/proto2/proto2.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto2/proto2.pb.go
@@ -4,9 +4,8 @@
 package proto2
 
 import (
-	bytes "bytes"
-	gzip "compress/gzip"
 	proto "github.com/golang/protobuf/proto"
+	protoapi "github.com/golang/protobuf/protoapi"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 	reflect "reflect"
@@ -89,13 +88,7 @@
 	0x61, 0x74, 0x61, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32,
 }
 
-var fileDescriptor_d756bbe8817c03c1_gzipped = func() []byte {
-	bb := new(bytes.Buffer)
-	zw, _ := gzip.NewWriterLevel(bb, gzip.NoCompression)
-	zw.Write(fileDescriptor_d756bbe8817c03c1)
-	zw.Close()
-	return bb.Bytes()
-}()
+var fileDescriptor_d756bbe8817c03c1_gzipped = protoapi.CompressGZIP(fileDescriptor_d756bbe8817c03c1)
 
 const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
 
diff --git a/cmd/protoc-gen-go/testdata/proto3/enum.pb.go b/cmd/protoc-gen-go/testdata/proto3/enum.pb.go
index 2e4d8b8..6db834e 100644
--- a/cmd/protoc-gen-go/testdata/proto3/enum.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto3/enum.pb.go
@@ -4,9 +4,8 @@
 package proto3
 
 import (
-	bytes "bytes"
-	gzip "compress/gzip"
 	proto "github.com/golang/protobuf/proto"
+	protoapi "github.com/golang/protobuf/protoapi"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 )
@@ -71,13 +70,7 @@
 	0x33, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
-var fileDescriptor_b4b9b1e8d161a9a6_gzipped = func() []byte {
-	bb := new(bytes.Buffer)
-	zw, _ := gzip.NewWriterLevel(bb, gzip.NoCompression)
-	zw.Write(fileDescriptor_b4b9b1e8d161a9a6)
-	zw.Close()
-	return bb.Bytes()
-}()
+var fileDescriptor_b4b9b1e8d161a9a6_gzipped = protoapi.CompressGZIP(fileDescriptor_b4b9b1e8d161a9a6)
 
 const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
 
diff --git a/cmd/protoc-gen-go/testdata/proto3/fields.pb.go b/cmd/protoc-gen-go/testdata/proto3/fields.pb.go
index a922f16..b353dca 100644
--- a/cmd/protoc-gen-go/testdata/proto3/fields.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto3/fields.pb.go
@@ -4,9 +4,8 @@
 package proto3
 
 import (
-	bytes "bytes"
-	gzip "compress/gzip"
 	proto "github.com/golang/protobuf/proto"
+	protoapi "github.com/golang/protobuf/protoapi"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 	reflect "reflect"
@@ -574,13 +573,7 @@
 	0x6f, 0x33, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
-var fileDescriptor_f1e3ea068187307c_gzipped = func() []byte {
-	bb := new(bytes.Buffer)
-	zw, _ := gzip.NewWriterLevel(bb, gzip.NoCompression)
-	zw.Write(fileDescriptor_f1e3ea068187307c)
-	zw.Close()
-	return bb.Bytes()
-}()
+var fileDescriptor_f1e3ea068187307c_gzipped = protoapi.CompressGZIP(fileDescriptor_f1e3ea068187307c)
 
 const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)