Repository navigation
v1.6.0
This release contains bug fixes and new features/APIs.
"github.com/jhump/protoreflect/codec"
Changes/fixes:
- The
Buffer.EncodeFieldValuemethod will now use always packed encoding for repeated fields that are so configured. Previously, it only used packed encoding when the repeated field actually contained more than one value. - Encoding messages should now be compatible with message types generated by v2 of the protobuf module.
"github.com/jhump/protoreflect/desc/protoparse"
Additions:
- The
Parserstruct has a new field namedLookupImport. When set, if an imported file cannot be loaded via the parser'sAccessor, this field will be invoked. UnlikeAccessor, this field supplies an already parsed descriptor instead of protobuf source code to parse. This allows for parsed files' dependencies to provided in already-parsed descriptor form instead of having to re-parse said dependencies.
Changes/fixes:
- The
ResolveFilenamesfunction has been modified so it should work as expected/documented on Windows platforms, not just platforms that use forward slash (/) as a path separator. - When parsing a file that contains an enum definition that has no values or a syntax error with one of the enum values, the parse operation would result in an "index out of range" panic. This has been fixed.
- Support was added for groups that have field options. This is a lesser-known feature of groups (which is a technically deprecated feature of the proto2 syntax). In addition to message options inside the group body (which this package already supported), they can also contain field-style options. For example:
This package now provides the same level of support for this as does
message Foo { optional group Bar = 1 [(field.option) = "baz1"] { option (msg.option) = "baz2"; } }protoc. Earlier versions of this package would have reported a syntax error at the opening bracket ([) of the field options.
"github.com/jhump/protoreflect/desc/protoprint"
Changes/fixes:
- Support was added for groups that have field options. See the addition described above for the "protoparse" package for more details. Previously, a descriptor for a group that had both field and message options would result in only the message options being printed. Now the "protoprint" package also correctly prints field options for such descriptors.
"github.com/jhump/protoreflect/dynamic"
Changes/fixes:
- When marshaling a dynamic message to the text format, if the message contained a string field value that contained a double-quote character (
"), the resulting text output would be invalid and unparseable. This has been fixed. - The
KnownTypeRegistryshould now correctly identify well-known types when using generated types in v2 of the protobuf module. - When marshaling a dynamic message that contained a map field with a
nilvalue (e.g. the value type is a message and the value stored in the map is anilpointer), the operation would panic. Now it serializes that map entry with no value (e.g. the synthetic message representing the map entry will be serialized with only a key and omit the value field). This is how the protobuf module'sprotopackage handles this scenario in generated messages with map fields.