Skip to content

v1.10.0

Compare
Choose a tag to compare
@jhump jhump released this 27 Sep 18:25
d296c5d

This release contains some improvements to the protoparse package and new functionality in the protoprint package.

"github.com/jhump/protoreflect/desc/protoparse"

Changes/fixes:

  • A couple of cases were identified where the protoc compiler would reject proto source, but the protoparse package would accept it:
    • The way protoc resolved relative names to fully-qualified names, for the request and response types in a method signature, differed slightly from protoparse. The protoparse package might accept a source program, but protoc might reject it due resolving a type name to something other than a type (such as a service or method name). This package now matches the behavior of protoc and will reject the same kinds of source.
    • The protoparse would accept a program with a range like 1to max, for example, whereas protoc requires a space between the 1 and the keyword to. This was due to a small difference in how tokens are lexed. The lexer in this package has been updated to now match the behavior of protoc and will now issue an error if there is no space between a numeric literal and subsequent identifier/keyword.
  • The protoc compiler accepts '\v' (vertical tab) and '\f' (form feed) characters as whitespace, but protoparse would not. This is now fixed.
  • The protoparse package could panic (with type assertion failures or with index-out-of-range failures) if the input contained a unicode code point in a particular range (well outside the range of allowed characters in a proto source file, other than inside string literals). This has been fixed.

"github.com/jhump/protoreflect/desc/protoprint"

Additions:

  • A new CustomSortFunction field has been added to the Printer type. This can be used to define a custom order in which elements are printed to a file. This also includes a new interface type, protoprint.Element, which custom sort functions can use to inspect the elements for deciding how to order them.