Repository navigation
v1.7.0
This release contains some bug fixes and some new API. Most of the new API is to support the new proto3 optional feature introduced with protoc 3.12 (aka "field presence in proto3").
"github.com/jhump/protoreflect/desc"
Additions:
- The
desc.FieldDescriptoranddesc.OneOfDescriptortypes have new methods related to "proto3 optional" fields:FieldDescriptor.IsProto3Optional,FieldDescriptor.HasPresence, andOneOfDescriptor.IsSynthetic.
"github.com/jhump/protoreflect/desc/builder"
Additions:
- The
builder.FieldBuildertype has a new bool fieldProto3Optionalas well as related methodSetProto3Optional, for working with and building "proto3 optional" fields.
"github.com/jhump/protoreflect/desc/protoparse"
Additions:
- Adds a new
WarningReportertype and field of the same name on theParsertype. When the field is populated (e.g. non-nil), the value will be used to report warnings. Currently, the only warning supported is for files that do not have asyntaxdeclaration. The reporter will receive a warning where the given error value isprotoparse.ErrNoSyntax.
Changes/fixes:
- This package now accepts source files that use the
optionalfield label forsyntax = "proto3"files. Like protoc, this results in a synthetic single-field oneof that wraps the optional field. - Fixes a panic that could occur when calling the
GetPositionfield of anErrorWithPosvalue returned by this package. This occurred when there were I/O errors (or other errors returned by the parser's file accessor) when accessing the top-level filenames requested for the parse operation. - When a custom error reporter is in use, the reporter can return nil to indicate that the operation should proceed. The spec states that even if the reporter returns nil and does not abort processing, the final result of the parse operation would be
protoparse.ErrInvalidSourceif any errors were reported. But for some errors (specifically: linking errors), errors could be reported but the final disposition would be successful. This has been remedied to correctly return an error if any errors are reported.
"github.com/jhump/protoreflect/desc/protoprint"
Changes/fixes:
- This package can now correctly print files that contain "proto3 optional" fields. Previously, it would explicitly print the synthetic one-of and not include the
optionallabel; that is now fixed.