812 Commits

Author SHA1 Message Date
Joe Tsai
5e85542f16 all: upgrade weak dependency to github.com/golang/protobuf@v1.4.0
Change-Id: I7e04b4fe0ef174dddc8c4938f8d6f2109581d883
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/228179
Reviewed-by: Damien Neil <dneil@google.com>
2020-04-13 20:03:07 +00:00
Joe Tsai
ba9d210a5c all: start v1.21.0-devel
Change-Id: Ib9df04de7a3f46f3a3b512e92cc7694ec0f4f927
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/228178
Reviewed-by: Damien Neil <dneil@google.com>
2020-04-13 18:57:37 +00:00
Joe Tsai
3b9eee1291 all: release v1.21.0
Change-Id: I6a91f3efd45ab0a446b220fddc8bd03aec93b388
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/228177
Reviewed-by: Damien Neil <dneil@google.com>
v1.21.0
2020-04-13 18:57:02 +00:00
Joe Tsai
7dfcffe5a7 internal/impl: handle extremely old messages
At some point in time, protoc-gen-go actually emitted an XXX_OneofFuncs
with a different signature. Adjust the logic for handling XXX_OneofFuncs
to not assume that the return arguments are in a specific order.

Change-Id: Idd9c09231c4129c655d4a635bb1ae094896a1ff4
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/226980
Reviewed-by: Damien Neil <dneil@google.com>
2020-04-02 21:12:23 +00:00
Joe Tsai
a75c9146b7 internal/impl: minor refactoring
Change-Id: I1a5f4ca31fec72a39ba6690af06f4ae8576408cc
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/226897
Reviewed-by: Damien Neil <dneil@google.com>
2020-04-02 00:23:08 +00:00
Damien Neil
188e702e78 reflect/protodesc: add NewFiles
Add a function that takes a protoreflect.FileDescriptorSet and returns
a protoregistry.Files.

Updates golang/protobuf##1065.

Change-Id: I2715d042053ef7d3f1bfcee1866c20cac423e327
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/226237
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2020-03-31 19:56:16 +00:00
Joe Tsai
d037755d51 internal/detectknown: add helper package to identify well-known types
Change-Id: Id54621b4b44522a350e6994074962852690b5d66
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/225257
Reviewed-by: Herbie Ong <herbie@google.com>
2020-03-24 23:06:32 +00:00
Joe Tsai
f8d77f810a internal/msgfmt: simply time formatting logic
The msgfmt formatter is intended to only for debugging purposes.
Remove unnecesary logic to detect out-of-range timestamps and durations.

Change-Id: I060149ed71aa892bbe4fdb2508b1d0b9df4b5f37
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/225258
Reviewed-by: Damien Neil <dneil@google.com>
2020-03-24 22:58:47 +00:00
Joe Tsai
28cb1e4f28 internal/impl: remove deprecated ExtensionField methods
These were originally needed by the legacy implementation,
but not anymore now that it fully wraps the new implementation.

Change-Id: I950958ebfcb7883fc4b72128d22eaba2da5cc62f
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/224583
Reviewed-by: Damien Neil <dneil@google.com>
2020-03-23 18:37:32 +00:00
Joe Tsai
8cbef3ff2d all: fix golint violations
Change-Id: I35d9f6842ec2e9b36c14672a05c4381441bda87a
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/224582
Reviewed-by: Herbie Ong <herbie@google.com>
2020-03-21 00:04:20 +00:00
Joe Tsai
4e847add50 README.md: mention protowire and protopack in the index
Change-Id: Ie817c2317838695010e4e225a1223ca6cc12ff73
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/224579
Reviewed-by: Damien Neil <dneil@google.com>
2020-03-20 22:19:18 +00:00
Joe Tsai
88baf0ae0c testing/protocmp: remove format.go
This is dead code as the logic has been moved to internal/msgfmt.

Change-Id: If65f443c9672f5fdfbb91c7cc64fb6f12a93c374
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/224658
Reviewed-by: Damien Neil <dneil@google.com>
2020-03-20 22:16:06 +00:00
Damien Neil
c92333953e internal/cmd/generate-protos: use module= generator option
Now we'll get a generator error if a file is missing a go_package
option.

Change-Id: I89eec716f86956e6c164a61f5531c140b74bc099
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/222378
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2020-03-20 21:35:56 +00:00
Damien Neil
ffbc5fdf5a compiler/protogen: add module= generator option
Add a generator option that strips a prefix from the generated
filenames.

Consider this case: We have google/protobuf/empty.proto, with a
go_package option of "google.golang.org/protobuf/types/known/emptypb".
We want to generate the code for this file, placing it into the
appropriate directory of our repository.

In the default mode used by the code generator (paths=import),
the generator outputs the file:

	google.golang.org/protobuf/types/known/emptypb/empty.pb.go

This is close to what we want, but has an unnecessary
"google.golang.org/protobuf/" prefix. In the GOPATH world, we could pass
--go_out=$GOPATH to protoc and get a generated file in the desired
location, but this path is not useful in the modules world.

The 'module' option allows us to strip off the module prefix, generating
the desired filename (types/known/emptypb/empty.pb.go):

	protoc --go_out=. --go_opt=module=google.golang.org/protobuf google/protobuf/empty.proto

The module name must be an exact, character-for-character match. This
matches protoc's file handling in general.

Default to and require the paths=import option when module= is
specified, since it only makes sense when combined with it.

Updates golang/protobuf#992.

Change-Id: Idbfe4826b6c0ece30d64dbc577131a4f16391936
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/219298
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2020-03-20 21:22:12 +00:00
Edward McFarlane
9d397869d8 types/dynamicpb: fix message Zero return type to read-only
Changes the message Zero return type to be read-only by omitting internal known map.

Change-Id: I1c1191a125df74251be3d8bb70f4b06c1ff57070
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/223857
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2020-03-20 19:41:50 +00:00
Joe Tsai
2ce1ca9e3f internal/msgfmt: use msgfmt package to format messages
Port message formatting logic in testing/protocmp to internal/msgfmt
and improve upon its output.

This formatter is optimized for humanly readable output.
It takes the best parts of both the JSON and proto text formats.

The good of prototext:
	* It supports emitting unknown fields (useful for debugging).
	* It is relatively concise in the common-case since keys do not
	need to be represented as quoted strings (e.g., "key" vs key).

The bad of prototext:
	* Requires relatively large dependency on encoding/prototext.
	* Our implementation lacks support for serializing packed lists.
	* Lacks support for readable maps.
	* Lacks support for readable Timestamp and Duration.

The good of protojson:
	* First-class support for readable maps.
	* First-class support for readable Timestamp and Duration.

The bad of protojson:
	* Requires relatively large dependency on encoding/protojson.
	* Lacks support for emitting unknown fields.
	* More verbose in the common-case as keys are quoted strings.

The msgfmt package has the benefits of both protojson and prototext,
but none of the detriments. It is a relatively simple implementation.

This output is only intended for human consumption with no associated
deserialization implementation.
To avoid any illusion that this is identical to either the proto text
or JSON formats, this always emits surrounding "{}" for
top-level messages and the keys are not quoted strings.

This CL does not use this format for generated Message.String methods
as there is concerns about being inconsistent with the String methods
as implemented in other languages. Having it be a seperate package makes
it trivial to switch over to this if desired.

Change-Id: I8b3581904d1624e84bf1b1954d2f01e5774b7f87
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/223752
Reviewed-by: Damien Neil <dneil@google.com>
2020-03-20 19:25:02 +00:00
Joe Tsai
cfd80493c5 testing/protopack: make package publicly available
Change-Id: I342ed27df17867f18c58e60880bcac5a31a3096b
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/219837
Reviewed-by: Damien Neil <dneil@google.com>
2020-03-20 18:05:51 +00:00
Joe Tsai
cd108d00a8 encoding/protowire: make package publicly available
Change-Id: I95e293c208e787a91d50e29817620535dfeaa7f2
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/219838
Reviewed-by: Damien Neil <dneil@google.com>
2020-03-20 07:42:18 +00:00
Joe Tsai
b738ac9285 all: regenerate remote .proto files
This fixes the conformance test failures which occur because the
conformance protos have not been regenerated.
The generator script has been modified with a sanity check that
files do not exist outside the expected sub-tree.

Change-Id: I473efec4a016f6bc96ddf7e20d54bcf5ff9b55fe
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/223538
Reviewed-by: Damien Neil <dneil@google.com>
2020-03-18 20:17:11 +00:00
Joe Tsai
6ad8e63055 compiler/protogen: allow specifying the package name with M flags
When using the M flags (which is functionally a mapping of
filenames to Go package paths), provide the user the ability to also
specify the package name by delimiting the package path with a ";".

Example usage:
	Mpath/to/foo.proto=path/to/foo_go_proto;foopb

This uses the exact same syntax as the go_package option where a
";" delimiter can be used to specify a package name.
It brings the M flags and the go_package option closer in behavior.

Change-Id: I98e1fbb66ec2f1b70b4143b305355e5ab35ea198
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/223819
Reviewed-by: Damien Neil <dneil@google.com>
2020-03-18 20:10:33 +00:00
Damien Neil
d3874051d7 internal/encoding/messageset: don't modify input data when unmarshaling
When combining multiple message fields in a MessageSet item (a case
which should never happen in practice), unmarshal could modify the input
data. Fix it to not do so. Add a general check to ensure that unmarshal
operations don't modify the input.

Change-Id: Idde46e6132a1dc96c374f9146efff81783c3bef3
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/223818
Reviewed-by: Joe Tsai <joetsai@google.com>
2020-03-18 05:27:34 +00:00
Joe Tsai
29677a9c11 types/dynamic: make Message implement legacy message interface
It's annoying for some users that they can't directly pass
*dynamicpb.Message to APIs that expect the legacy message interfaces.
The proto.MessageV1 wrappers work, but is somewhat suspect since they
were originally designed to wrap legacy generated messages.

Change-Id: I0f9900dcd1c9865c754551f8763680c9bb904813
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/223817
Reviewed-by: Damien Neil <dneil@google.com>
2020-03-17 23:08:45 +00:00
Joe Tsai
b4c73aa919 testing/protocmp: add SortRepeated and SortRepeatedFields
SortRepeated is similar to cmpopts.SortSlice where it accepts a
user-provided sort function, but only operates on repeated fields.
It pattern matches based on sort element type.

SortRepeatedFields is similar to SortRepeated, but chooses an
arbitrary sort order for the specified (by name) repeated fields.
It pattern matches based on message field name.

Change-Id: Ib6ef282e5394cf7b22522161d524f22e1b76677a
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/221432
Reviewed-by: Damien Neil <dneil@google.com>
2020-03-17 22:58:48 +00:00
Damien Neil
aadba562d3 compiler/protogen: make paths=import work with M overrides
In the default .pb.go filename generation mode, we generate the filename
from the import path when a file has a go_package option and the source
.proto filename otherwise.

Change filename generation when an explicit mode of paths=import is
specified to always use the import path, no matter how it was
determiend. The practical effect is that you can override the import
path of a file with Mx.proto=import/path and have this behave
identically to setting a go_package option in the file.

Change-Id: I954b3f9d5fd17d08896629bfc77945dea1732bd6
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/219597
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2020-03-16 20:43:34 +00:00
Joe Tsai
92af527de9 internal/impl: remove Export.ExtensionDescFromType
This is no longer needed by the old implementation.

Change-Id: I3ba02d37f35f599ec790ec4e627258273883a308
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/223279
Reviewed-by: Damien Neil <dneil@google.com>
2020-03-13 23:34:19 +00:00
Joe Tsai
4ab2bc9bb7 internal/version: move version information to internal package
Change-Id: I947876de5d290cf783d9ba798871725e77e16517
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/223277
Reviewed-by: Damien Neil <dneil@google.com>
2020-03-13 19:57:50 +00:00
Joe Tsai
f92988f900 all: upgrade protobuf to v3.11.4
This introduces some conformance test failures,
which occur not because our implementation changed behavior,
but because new cases were added.

Future work will be to investigate these failuress.

Change-Id: Ifb17465883c417acd46865744572f8cd0c858383
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/222857
Reviewed-by: Damien Neil <dneil@google.com>
2020-03-13 19:49:20 +00:00
Joe Tsai
f75a338d9c test.bash: update Go to v1.12.17, v1.13.8, and v1.14
Change-Id: I5c8627290f02c4506e7ea07f5dce903bfbfef00e
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/212221
Reviewed-by: Damien Neil <dneil@google.com>
2020-03-11 02:07:34 +00:00
Joe Tsai
a56bd81046 all: start v1.20.1-devel
Change-Id: Ie2940cd41fd3c449b2233e1bc3b6ba5ba91038f2
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/222699
Reviewed-by: Damien Neil <dneil@google.com>
2020-03-09 21:07:39 +00:00
Joe Tsai
290f718d07 all: release v1.20.1
Change-Id: I77c61b55d3c6aa540103ffe82c9dd226959bb753
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/222698
Reviewed-by: Damien Neil <dneil@google.com>
v1.20.1
2020-03-09 21:07:25 +00:00
Joe Tsai
676bcfb6fd all: use github.com/golang/protobuf@v1.4.0-rc.4
Change-Id: Ic5f0bd644b4234204d90fa747b780409abf7917d
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/222680
Reviewed-by: Damien Neil <dneil@google.com>
2020-03-09 21:03:34 +00:00
Joe Tsai
1718d82dda README.md: add link to blog announcement
Change-Id: Ibeddd40f2a11bfb4ec60f917341513349e788f56
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/222697
Reviewed-by: Damien Neil <dneil@google.com>
2020-03-09 20:40:04 +00:00
Joe Tsai
e05f789c09 proto: fix signature of UnmarshalState and MarshalState
The pseudo-internal MarshalState and UnmarshalState method should
not have a seperate Message argument since it is passed in through
the extensible MarshalInput and UnmarshalInput values.

Change-Id: I838aadaee30e91cdf888ab024e65348c73c1cd7e
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/222678
Reviewed-by: Damien Neil <dneil@google.com>
2020-03-09 20:02:17 +00:00
Joe Tsai
ea6e3da5ef internal/testprotos/legacy: avoid direct dependency on github.com/golang/protobuf
Change-Id: I42b17ae672a76d91ecbeeb2c12949002d7720524
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/222677
Reviewed-by: Damien Neil <dneil@google.com>
2020-03-09 19:39:04 +00:00
Damien Neil
e358d430e7 compiler/protogen: disable warnings in tests
Change-Id: I80ff3c31dc1039a833e6c962d5f3fc6e0aa46f6a
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/222377
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
Reviewed-by: Herbie Ong <herbie@google.com>
2020-03-09 17:16:35 +00:00
renthraysk
a30b571f93 protobuf-go/internal/encoding/wire: SizeVarint optimisation
Replace division by 7 in SizeVarint(). The previous method was optimised by the compiler to use a 64bit multiplication.
This uses 9/64 as 1/7 and unsigned 32bit multiplication (which compiler can optimise further using scaling address modes, lea (ax,ax*8),ax)) and a shift.)

protobuf-go/internal/benchmarks/micro benchmark

name                            old time/op  new time/op  delta
EmptyMessage/Wire/Marshal-4     40.0ns ± 1%  39.9ns ± 5%    ~     (p=0.683 n=5+5)
EmptyMessage/Wire/Unmarshal-4   20.5ns ± 2%  20.3ns ± 2%    ~     (p=0.317 n=5+5)
EmptyMessage/Wire/Validate-4    21.5ns ± 0%  21.5ns ± 1%    ~     (p=0.825 n=4+5)
EmptyMessage/Clone-4             135ns ± 2%   136ns ± 1%    ~     (p=0.365 n=5+5)
RepeatedInt32/Wire/Marshal-4    4.06µs ± 1%  3.69µs ± 1%  -9.05%  (p=0.008 n=5+5)
RepeatedInt32/Wire/Unmarshal-4  4.72µs ± 0%  4.55µs ± 2%  -3.74%  (p=0.008 n=5+5)
RepeatedInt32/Wire/Validate-4   3.08µs ± 2%  2.94µs ± 0%  -4.69%  (p=0.008 n=5+5)
RepeatedInt32/Clone-4           1.09µs ± 1%  1.09µs ± 0%    ~     (p=0.810 n=5+5)
Required/Wire/Marshal-4          296ns ± 1%   293ns ± 0%  -0.95%  (p=0.000 n=5+4)
Required/Wire/Unmarshal-4        147ns ± 1%   135ns ± 1%  -8.17%  (p=0.008 n=5+5)
Required/Wire/Validate-4         127ns ± 2%   123ns ± 0%  -3.15%  (p=0.000 n=5+4)
Required/Clone-4                 393ns ± 1%   391ns ± 2%    ~     (p=0.238 n=5+5)

Change-Id: Idfe75a9cd80b2bddaf13a8e879403c0c94ebc419
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/221803
Reviewed-by: Damien Neil <dneil@google.com>
2020-03-06 15:28:51 +00:00
Damien Neil
13e7f145cc reflect/protoregistry: avoid deadlock in registration
Under some rare circumstances registration can deadlock
when lazy descriptor initialization consults the registry.

Move the call triggering the lazy init out of the critical section.

Fixes golang/protobuf#1052.

Change-Id: Ic266e06b0db99fea65e797b879ce53e5342fff95
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/204804
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2020-03-05 17:35:16 +00:00
Damien Neil
e1c61a307e internal/encoding/messageset: fix decoding of some invalid data
For historical reasons, MessageSets items are allowed to have field
numbers outside the usual valid range. Detect the case where the field
number cannot fit in an int32 and report an error. Also check for
a field number of 0 (always invalid).

Handle the case where a MessageSet item includes an unknown field.
We have no place to put the contents of the field, so drop it. This is,
I believe, consistent with other implementations.

Change-Id: Ic403427e1c276cbfa232ca577e7a799cce706bc7
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/221939
Reviewed-by: Herbie Ong <herbie@google.com>
2020-03-04 02:12:26 +00:00
Damien Neil
969537aa29 all: start post-v1.20.0 devel
Change-Id: I811fab64a8a22288760beef04021ded63bc4ea9b
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/221784
Reviewed-by: Herbie Ong <herbie@google.com>
2020-03-02 19:36:27 +00:00
Damien Neil
aa81c06513 all: release v1.20.0
Change-Id: I3bc9d46f836535393059b9a73e8364211eee9e38
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/221783
Reviewed-by: Herbie Ong <herbie@google.com>
v1.20.0
2020-03-02 18:51:28 +00:00
Damien Neil
0f2b33b67a reflect/protoregistry: add link to namespace conflict FAQ
Updates golang/protobuf#1039.

Change-Id: Ia9f80da5dab1e6cd3cf9ad512b78b63b32065c31
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/221782
Reviewed-by: Herbie Ong <herbie@google.com>
2020-03-02 18:04:46 +00:00
Joe Tsai
fea7d5276d all: start v1.20.0-rc.1.devel
Change-Id: I7a88cf90c9b2ee61d6eae5019829362a7dce164f
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/221598
Reviewed-by: Damien Neil <dneil@google.com>
2020-02-29 07:48:10 +00:00
Joe Tsai
a6bf928d57 all: release v1.20.0-rc.1
Change-Id: I383cd3e94788f80b95f3ef7f1b86922fc0ea1db3
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/221597
Reviewed-by: Damien Neil <dneil@google.com>
2020-02-29 07:47:16 +00:00
Joe Tsai
65466b8cf4 all: update weak dependency to github.com/golang/protobuf@v1.4.0-rc.2
Change-Id: I1af402a44c8d113ce50e60523e4c6d8397dbb520
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/221434
Reviewed-by: Damien Neil <dneil@google.com>
2020-02-29 02:36:55 +00:00
Damien Neil
6e36304a32 reflect/protoreflect: ExtensionRangeOptions never returns nil
Documentation only change.

Change-Id: Ib620efc99bdaab90eeb5404554ae442f345d6f47
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/221560
Reviewed-by: Joe Tsai <joetsai@google.com>
2020-02-28 23:53:49 +00:00
Joe Tsai
ab0ca4ff8a compiler/protogen: use consistent options pattern
Throughout the module options usually expressed as a struct where the
acting function is a method hanging off the options type.
Use this pattern for protogen as well.

Change-Id: I533a61387cb74971e4efc9313d400b66b8aac451
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/221424
Reviewed-by: Damien Neil <dneil@google.com>
2020-02-28 23:03:10 +00:00
Joe Tsai
c14e7899f9 testing/protocmp: fix reflection handling of extensions
Extensions should be checked based on ContainingMessage,
rather than the Parent. Add tests to ensure this works.

Change-Id: Iaf257f65197fb8d332039bc77a192753f8c4159f
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/221426
Reviewed-by: Damien Neil <dneil@google.com>
2020-02-28 21:49:08 +00:00
Joe Tsai
a56742be04 all: update README.md
Change-Id: I11f37f0563b1b15184da2fd4a5325231519aa03f
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/221238
Reviewed-by: Damien Neil <dneil@google.com>
2020-02-28 21:47:40 +00:00
Joe Tsai
ca0b25e48f testing/protocmp: automatically promote message values
For user convenience, automatically transform message values by
shallow copying them if necessary. Storing messages as values is
frowned upon, but is sometimes done by APIs that a user does not own.

Change-Id: I7e927d1a1e050bf4cea1aa889f56d23e99355f26
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/221423
Reviewed-by: Damien Neil <dneil@google.com>
2020-02-27 23:42:48 +00:00
Joe Tsai
a89afdc06f testing/protocmp: make Message implement proto.Message
By having the Message type implement proto.Message, it can be passed
to other general-purpose protobuf functions such as proto.Merge.
This provides a convenient way to convert the Message back into a
concrete form that may be easier to work with.

A minor consequence of this change is that invalid messages are
converted to an invalid Message that preserves type information.
Previously, they were simply transformed to a nil Message.

Change-Id: I6fca8a0879408c7f44a99d52734613302fa23f70
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/221422
Reviewed-by: Damien Neil <dneil@google.com>
2020-02-27 23:32:22 +00:00