Commit Graph

752 Commits

Author SHA1 Message Date
Joe Tsai
bb941fe881 cmd/protoc-gen-go/testdata: remove go.mod file
In the distant past this was necessary because:
1) the generated code depended on github.com/golang/protobuf,
but now it doesn't.
2) protoc-gen-go-grpc had a dependency on google.golang.org/grpc,
and the seperate go.mod file allowed us to isolate the dependency,
but that binary doesn't exist here anymore.

Drop the go.mod file for cmd/protoc-gen-go/testdata.

Change-Id: I7341d78dc346bd82e5c68ed48cee3275b6296249
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/220502
Reviewed-by: Damien Neil <dneil@google.com>
2020-02-24 22:15:38 +00:00
Joe Tsai
9118b11cd8 all: update contributing documentation
Change-Id: I2815e570696fd5ffc765c42ffc26060fc4aa5a2b
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/220677
Reviewed-by: Damien Neil <dneil@google.com>
2020-02-24 22:15:07 +00:00
Joe Tsai
764a9d16a6 cmd/protoc-gen-go: add link to devsite for protoc-gen-go
Change-Id: I67a0897df42e177782ec76bb307ea2334f86975e
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/220596
Reviewed-by: Damien Neil <dneil@google.com>
2020-02-24 22:13:41 +00:00
Joe Tsai
222a0006a6 compiler/protogen: add devsite URL to protogen warnings
Change-Id: Ida47b31a4f62d00d9f756da6da98cd852f36bb69
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/220594
Reviewed-by: Damien Neil <dneil@google.com>
2020-02-24 20:14:07 +00:00
Damien Neil
37cbbeb558 internal/impl: check for size cache overflow
The size cache is an int32. Store a -1 in it if the message size
overflows, and fall back to recomputing the size if the value is
negative. This means lamentable O(N^2) costs in marshaling,
but that's better than silently producing invalid output.

Also considered: Return an error. Avoids O(N^2) behavior, but gives the
user no good choices if they don't care the output being slow. Encoding
costs of messages this large are likely to be dominated by copying the
bytes rather than the size operation anyway, so slow-but-correct seems
like the most generally useful option.

We could store valid values for the range (0x7fffffff,0xfffffffe)
reserving only 0xffffffff as the overflow sentinel, but optimizing this
case seems less important than the code being obviously correct.

Fixes golang/protobuf#970.

Change-Id: I44f59ff81fdfbc8672dd5aec959d5153a081aab9
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/220593
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2020-02-24 20:12:47 +00:00
Joe Tsai
a88c3c4068 all: remove reliance on --compact-summary
This flag is recently added to git. Avoid it for now.

Change-Id: I007f3cc12ec6ef37bc6d70ddc346b7af7983879e
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/220501
Reviewed-by: Damien Neil <dneil@google.com>
2020-02-22 01:19:34 +00:00
Damien Neil
4d8936d0db all: fail faster on dirty working tree
It's annoying to get through all the tests for five different language
versions to discover at the end that you've got an uncommitted file
sitting around in your working tree, or you forgot to run
regenerate.bash.

Report uncommitted changes at the start of tests (so you can ^C and
fix the problem right off if you didn't know about it), but hold off on
failing the test until the end so you can still run tests on uncommitted
changes.

Fail immediately if generated files are out of date.

Change-Id: I12feaecaa3c5038ac0a4cca9cc9ff3447b57a08a
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/220517
Reviewed-by: Joe Tsai <joetsai@google.com>
2020-02-21 19:16:35 +00:00
Damien Neil
3a18560b88 all: add a test for copyright headers
Fix a few files with no or unusual copyright headers.

Manually add copyright headers to the legacy testprotos, which will
(probably) never be regenerated.

Change-Id: Ifb52fa0eb59bf9d2de40b8df7e581a3c9731c883
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/220498
Reviewed-by: Joe Tsai <joetsai@google.com>
2020-02-21 18:41:46 +00:00
Damien Neil
2a63c7aa61 internal/cmd: print generated filename only when contents change
Printing the filenames of regenerated files only when the contents
change makes it easier to tell when a change has produced the expected
result in the generated file output.

Change-Id: I74d0020be1de3d287bb8400ba290131008859bf1
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/220356
Reviewed-by: Joe Tsai <joetsai@google.com>
2020-02-21 17:59:52 +00:00
Damien Neil
befd2dd2d4 cmd/protoc-gen-go-grpc: remove
Change-Id: I8bc67d71a6431807f0a6975dfc416cca56a28c7f
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/220355
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2020-02-21 17:30:00 +00:00
Damien Neil
56786dc5df testing/prototest: refactor prototest API
For consistency with other options types in the protobuf module, make
the test function a method of the options.

Drop the ExtensionTypes option and just look up the extension types to
test with in the provided resolver.

Change-Id: I7918bd10b7c003e4af56d27521d30218653d5b4d
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/219142
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2020-02-20 22:47:27 +00:00
Joe Tsai
fb5fde41cd internal/impl: remove blocking TODO
This TODO doesn't need to be addressed for v2 release.
Addressing this now would probably need to go through global testing,
which is not worth the effort now.

Change-Id: I44bf45e077c00e9a6462905193efb0bce41e9dd2
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/220345
Reviewed-by: Damien Neil <dneil@google.com>
2020-02-20 22:43:06 +00:00
Damien Neil
929c287d2b internal/testprotos: add a missing Copyright header line
Change-Id: Idb92e34af7c5342e4c4478707eb99fcb824d7606
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/220350
Reviewed-by: Joe Tsai <joetsai@google.com>
2020-02-20 22:40:12 +00:00
Joe Tsai
f26a9e7e30 all: rename IsInitialized as CheckInitialized
An Is prefix implies it returns a boolean.
A Check prefix better suggests that it could return an error.

Change-Id: I6ffcb32099a944c656c07654c294a0980efb2d0e
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/220338
Reviewed-by: Damien Neil <dneil@google.com>
2020-02-20 20:45:40 +00:00
Joe Tsai
5e75048cc1 all: fix license header
Change-Id: Ied2d1b07b90891c916a877e39ec9cdf49ff6b0be
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/220347
Reviewed-by: Damien Neil <dneil@google.com>
2020-02-20 20:27:29 +00:00
Joe Tsai
3df87a0b61 runtime/protoiface: remove IsInitializedOutputFlags and IsInitialized
The IsInitialized flag is unused and unnecessary as the error returned
inherently reports whether a message is uninitialized if it is non-nil.

Also cleanup the documentation in protoiface of stale references.

Change-Id: Id75772f4f75f8d7a2a9fbe772d57f7d69ae9fb9d
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/220337
Reviewed-by: Damien Neil <dneil@google.com>
2020-02-20 19:26:44 +00:00
Joe Tsai
52ee491c59 reflect/protoreflect: improve documentation
Change-Id: I3942f9790be2d1d84578154645384018a5e1546e
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/220342
Reviewed-by: Damien Neil <dneil@google.com>
2020-02-20 19:07:56 +00:00
Joe Tsai
6af2cee096 reflect/protodesc: improve documentation
Change-Id: Id1c0e0e702a7b0eb011c71de23cd5be76345d741
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/220341
Reviewed-by: Damien Neil <dneil@google.com>
2020-02-20 19:04:51 +00:00
Joe Tsai
04f03cb038 compiler/protogen: improve documentation
Change-Id: I68e918d297716178bc1d9f459edb1cd1678d4159
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/220340
Reviewed-by: Damien Neil <dneil@google.com>
2020-02-20 19:04:19 +00:00
Damien Neil
0232edc1d7 all: remove stray "." from license headers
Remove a stray bit of punctuation that crept into one of the license
headers and got copied around everywhere.

Change-Id: Iebe4e882650ab6dab28f132b5e324e2ab0b99a73
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/220339
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2020-02-20 18:54:38 +00:00
Damien Neil
466dd77288 all: fast-path method refactoring
Move all fast-path inputs and outputs into the Input/Output structs.
Collapse all booleans into bitfields.

Change-Id: I79ebfbac9cd1d8ef5ec17c4f955311db007391ca
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/219505
Reviewed-by: Joe Tsai <joetsai@google.com>
2020-02-19 22:01:50 +00:00
Damien Neil
3dbd95a558 reflect/protoreflect: add List.AppendMutable and Map.Mutable
Add methods to add a new, mutable message to a list or map, matching the
existing Message.Mutable.

These methods are purely a convenience, as each can be implemented in
terms of the existing interface.

Change-Id: I889c20fe37ea0f2a566555212e99e6378fb9fe1d
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/220117
Reviewed-by: Joe Tsai <joetsai@google.com>
2020-02-19 20:35:39 +00:00
Damien Neil
c4051cd4ec types/known: remove packages present in genproto
Remove the generated proto packages that already exist in
google.golang.org/genproto. We want to eventually move these
packages here, but it doesn't need to happen yet.

Add a local copy of fieldmaskpb for use in tests.

Refactor proto generation to override import paths using the
M<source>=<import_path> compiler option instead of by patching the
source files.

Change-Id: I8d31f67e931d70140182f19f3e0106111f71c4b4
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/219598
Reviewed-by: Joe Tsai <joetsai@google.com>
2020-02-18 22:04:05 +00:00
Damien Neil
725bfeaf40 internal/impl: support legacy Merger interface
Change-Id: I796be0bb1bb40605073228446364f3a2f1073ef1
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/219557
Reviewed-by: Joe Tsai <joetsai@google.com>
2020-02-18 17:00:39 +00:00
Joe Tsai
91b2604634 encoding: re-arrange options
Move Multiline and Indent to the top so that there is a separation
between options with semantic significance and those that are merely
for aesthetic purposes.

Change-Id: Icd5ee94ec010db8139a5e720f5b9842274fb3755
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/219500
Reviewed-by: Damien Neil <dneil@google.com>
2020-02-15 00:27:14 +00:00
Joe Tsai
5b335f7203 reflect/protoreflect: update documentation
There were a few stale references due to renamed identifiers.

Change-Id: I0ac7eda93c46143292799c3806214dc89f1e80cd
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/219504
Reviewed-by: Damien Neil <dneil@google.com>
2020-02-15 00:23:47 +00:00
Damien Neil
e8e8875f94 proto, runtime/protoiface, internal/impl: add fast-path Merge
Comparing -tags=protoreflect to fast-path:

name                              old time/op    new time/op    delta
pkg:google.golang.org/protobuf/internal/benchmarks goos:linux goarch:amd64
/Clone/google_message1_proto2-12    1.70µs ± 1%    0.30µs ± 1%  -82.64%  (p=0.001 n=7+7)
/Clone/google_message1_proto3-12    1.01µs ± 1%    0.19µs ± 1%  -80.77%  (p=0.000 n=7+8)
/Clone/google_message2-12            818µs ± 8%     141µs ± 6%  -82.78%  (p=0.000 n=8+8)
pkg:google.golang.org/protobuf/internal/benchmarks/micro goos:linux goarch:amd64
EmptyMessage/Clone-12               51.1ns ± 1%    39.3ns ± 3%  -23.03%  (p=0.000 n=7+8)
RepeatedInt32/Clone-12              24.5µs ± 1%     1.1µs ± 3%  -95.64%  (p=0.000 n=8+8)
Required/Clone-12                    978ns ± 1%     132ns ± 2%  -86.46%  (p=0.000 n=8+8)

name                              old alloc/op   new alloc/op   delta
pkg:google.golang.org/protobuf/internal/benchmarks goos:linux goarch:amd64
/Clone/google_message1_proto2-12    1.08kB ± 0%    0.74kB ± 0%  -31.85%  (p=0.000 n=8+8)
/Clone/google_message1_proto3-12      872B ± 0%      544B ± 0%  -37.61%  (p=0.000 n=8+8)
/Clone/google_message2-12            602kB ± 0%     411kB ± 0%  -31.65%  (p=0.000 n=8+8)
pkg:google.golang.org/protobuf/internal/benchmarks/micro goos:linux goarch:amd64
EmptyMessage/Clone-12                96.0B ± 0%     64.0B ± 0%  -33.33%  (p=0.000 n=8+8)
RepeatedInt32/Clone-12              25.4kB ± 0%     3.2kB ± 0%  -87.33%  (p=0.000 n=8+8)
Required/Clone-12                     416B ± 0%      256B ± 0%  -38.46%  (p=0.000 n=8+8)

name                              old allocs/op  new allocs/op  delta
pkg:google.golang.org/protobuf/internal/benchmarks goos:linux goarch:amd64
/Clone/google_message1_proto2-12      52.0 ± 0%      21.0 ± 0%  -59.62%  (p=0.000 n=8+8)
/Clone/google_message1_proto3-12      33.0 ± 0%       3.0 ± 0%  -90.91%  (p=0.000 n=8+8)
/Clone/google_message2-12            22.3k ± 0%      7.5k ± 0%  -66.41%  (p=0.000 n=8+8)
pkg:google.golang.org/protobuf/internal/benchmarks/micro goos:linux goarch:amd64
EmptyMessage/Clone-12                 3.00 ± 0%      2.00 ± 0%  -33.33%  (p=0.000 n=8+8)
RepeatedInt32/Clone-12               1.51k ± 0%     0.00k ± 0%  -99.80%  (p=0.000 n=8+8)
Required/Clone-12                     51.0 ± 0%      18.0 ± 0%  -64.71%  (p=0.000 n=8+8)

Change-Id: Ife9018097c34cb025dc9c4fdd9a61b2f947853c6
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/219147
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2020-02-14 21:47:10 +00:00
Damien Neil
7059483cfd all: update go.mod in submodules
Change-Id: Ibeabaecd3ba55b03dea554fc9fd28f647e9c66fd
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/219398
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2020-02-14 21:20:35 +00:00
Damien Neil
06e51b76b4 internal/weakdeps: put APIv1 weak dependency behind a build constraint
By using a build constraint that is never satisfied, we can add a weak
dependency on a module. If the module is part of a build, our go.mod
enforces a minimum version on it, but we never add it to the build
dependencies ourselves.

This is the same trick used for tool dependencies:
https://github.com/golang/go/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module

Dropped the TODO to remove the APIv1 dependency, since I think this
removes any need to do so.

Change-Id: I45b1a3f45535bcdc9abf34fb562d2869f1712bb6
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/219499
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2020-02-14 21:08:34 +00:00
Joe Tsai
5ca8f849d3 reflect/protoregistry: minor doc change
Clarify what the return bool of the Range callback does.

Change-Id: Ib584e48df9fa1c8053652cd4105b343316729719
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/219503
Reviewed-by: Damien Neil <dneil@google.com>
2020-02-14 20:45:52 +00:00
Joe Tsai
b08bc6ee84 proto: minor doc changes
Change-Id: I9e74b6b68a0bfe96381f224df7c56e49795d17d6
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/219501
Reviewed-by: Damien Neil <dneil@google.com>
2020-02-14 20:44:53 +00:00
Joe Tsai
6320bdfa7e types/dynamicpb: minor doc change
Change-Id: I13439b810e18142d85f4466be006d3abf3a66c30
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/219502
Reviewed-by: Damien Neil <dneil@google.com>
2020-02-14 20:42:33 +00:00
Joe Tsai
d7b9f5c093 proto: document the relationship between v1 and v2 messages
Change-Id: I1da929ce1d4e44adce9ef406cfd937973d2a8cc6
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/219139
Reviewed-by: Damien Neil <dneil@google.com>
2020-02-14 20:42:20 +00:00
Damien Neil
aa735f3cca internal/testprotos: add missing go_package option
Change-Id: If28f15266349b2c05c209202c38bc98dc43f7dbd
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/219297
Reviewed-by: Joe Tsai <joetsai@google.com>
2020-02-14 00:45:09 +00:00
Damien Neil
baf64d5536 all: depend on github.com/golang/protobuf@1.4.0-rc1
While this module has no actual dependency on APIv1, we want to ensure
that programs using both APIv1 and APIv2 use a version of APIv1 that
wraps APIv2.

Updates golang/protobuf#1032.

Change-Id: Ie69ce2930c843a7232c79b21ff418c53b28ed1af
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/219382
Reviewed-by: Joe Tsai <joetsai@google.com>
2020-02-13 23:28:41 +00:00
Joe Tsai
709e7c8474 protoreflect: adjust documentation
After a header, there needs to be a paragraph in order for godoc
to recognize the header as a header.

Change-Id: I6c814b24dbb5eb2d5efcb0040556521c05587393
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/219140
Reviewed-by: Damien Neil <dneil@google.com>
2020-02-13 06:14:06 +00:00
Damien Neil
c7aa53a3e0 proto: refactor merge tests
Use protobuild to generate test messages, both to simplify generating
proto2/proto3/extension variants of each test where appropriate and
to make it easier to test alternative message generators in the future.

Add various additional merge tests.

Change-Id: I4ba3ce232304e1d8325543680e2b6aae61de7364
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/219146
Reviewed-by: Joe Tsai <joetsai@google.com>
2020-02-12 19:41:50 +00:00
Damien Neil
cf33a9a274 proto: remove shallow merge support, and MergeOptions
We're still debating what the semantics of shallow merges should be, and
what the use case for them (if any) is. There's no need to commit
ourselves to this feature at this time; drop it for now.

Remove the exported MergeOptions type, since the only option is gone. We
can trivially add it back in the future if we need it.

Change-Id: I4c8697cae69cc66eed1ea65de84b982f20e1be44
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/219145
Reviewed-by: Joe Tsai <joetsai@google.com>
2020-02-12 19:18:33 +00:00
Damien Neil
316febd1ab internal/impl: pass *coderFieldInfo into fast-path functions
Refactor the fast-path size, marshal, unmarshal, and isinit functions to
take the *coderFieldInfo for the field as input.

This replaces a number of closures capturing field-specific information
with functions taking that information as an explicit parameter.

Change-Id: I8cb39701265edb7b673f6f04a0152d5f4dbb4d5d
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/218937
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2020-02-12 18:34:15 +00:00
Joe Tsai
f26172248d proto: add Merge tests for aberrant inputs
The generated Go code does not perfectly represent the protobuf data model.
As such, it is possible to construct Go message values that could not
otherwise be constructed through Unmarshal or Merge.
This CL adds a test to exercise some of the boundary conditions.
The tests do not necessarily lock in the current behavior, but provides
a way for us to know when they have changed (either intentionally or not).

Change-Id: I389ef97c2fcf037595ad553baf5270d7bee9673b
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/196738
Reviewed-by: Damien Neil <dneil@google.com>
2020-02-12 18:14:09 +00:00
Joe Tsai
e76af4be5e proto: document reset memory aliasing guarantees
Change-Id: I2dc79c362278b6bc9ccf531067701cba5c392a50
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/219141
Reviewed-by: Damien Neil <dneil@google.com>
2020-02-12 18:11:04 +00:00
Joe Tsai
25fc6fb4f2 reflect/protodesc: add FileOptions
The FileOptions type provides the ability to specify specialized options
for how a file descriptor is constructed. It follows the same optional
arguments pattern as used in the proto package.

The resolver is not an option since it almost always necessary
when constructing a file descriptor.

Change-Id: Ib98ac6289881ad8402dd615f6c895da5899cb8d9
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/218940
Reviewed-by: Damien Neil <dneil@google.com>
2020-02-11 23:14:57 +00:00
Herbie Ong
d2ece139c6 encoding/protojson: refactor to follow prototext pattern
All unmarshaling error messages now contain line number and column
information, except for the following errors:
- `unexpected EOF`
- `no support for proto1 MessageSets`
- `required fields X not set`

Changes to internal/encoding/json:
- Moved encoding funcs in string.go and number.go into encode.go.
- Separated out encoding kind constants from decoding ones.
- Renamed file string.go to decode_string.go.
- Renamed file number.go to decode_number.go.
- Renamed Type struct to Kind.
- Renamed Value struct to Token.
- Token accessor methods no longer return error.
  Name, Bool, ParsedString will panic if called on the wrong kind.
  Float, Int, Uint has ok bool result to check against.
- Changed Peek to return Token and error.

Changes to encoding/protojson:
- Updated internal/encoding/json API calls.
- Added line info on most unmarshaling error messages and kept
  description simple and consistent.

Change-Id: Ie50456694f2214c5c4fafd2c9b9239680da0deec
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/218978
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2020-02-11 22:59:08 +00:00
Joe Tsai
3b512245dc cmd/protoc-gen-go: add compile-time assertion for legacy proto package version
Change-Id: I2bc71dae34b5af379838239210cc04e3e3547d2b
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/218939
Reviewed-by: Damien Neil <dneil@google.com>
2020-02-11 00:43:10 +00:00
Joe Tsai
93bccf763e all: scrub all TODOs
TODOs that we do not intend to address have been deleted.
Those that are blocking v2 release are marked with "blocks".

Change-Id: I7efa9e546d0637b562101d0edc7009893d762722
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/218878
Reviewed-by: Damien Neil <dneil@google.com>
2020-02-10 19:28:48 +00:00
Damien Neil
604cdd2d2a proto: add package docs
Change-Id: I7c0b1e3a3b6cc1830b8e39e0ba66f1e4c06b7d12
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/218621
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2020-02-09 08:35:44 +00:00
Damien Neil
ee206b9211 proto: add tests for groups in oneofs
Fixes golang/protobuf#1000.

Change-Id: I9904f6496240c544b0190a8a1bc3e6d067f98f82
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/218581
Reviewed-by: Joe Tsai <joetsai@google.com>
2020-02-07 23:35:43 +00:00
Damien Neil
01b51b4f96 proto, internal/errors: add Error sentinel, errors.Wrap
Add a sentinel proto.Error error which matches all errors returned by
packages in this module.

Document that protoregistry.NotFound is an exact sentinel value for
performance reasons.

Add a Wrap function to the internal/errors package and use it to wrap
errors from outside sources (resolvers). Wrapped errors match
proto.Error.

Fixes golang/protobuf#1021.

Change-Id: I45567df3fd6c8dc9a5caafdb55654827f6fb1941
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/215338
Reviewed-by: Joe Tsai <joetsai@google.com>
2020-02-07 21:09:48 +00:00
Damien Neil
9afe9bb78b internal/impl: validate messagesets
Change-Id: Id90bb386e7481bb9dee5a07889f308f1e1810825
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/218438
Reviewed-by: Joe Tsai <joetsai@google.com>
2020-02-07 20:06:04 +00:00
Damien Neil
f9d4fdf054 internal/impl: fix validation of required group fields
Change-Id: I3c3b5cfbea599dc08096aa5992b7829c2e50f25d
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/218578
Reviewed-by: Joe Tsai <joetsai@google.com>
2020-02-07 20:05:54 +00:00