v1.10.0
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 theprotoparse
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 fromprotoparse
. Theprotoparse
package might accept a source program, butprotoc
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 ofprotoc
and will reject the same kinds of source. - The
protoparse
would accept a program with a range like1to max
, for example, whereasprotoc
requires a space between the1
and the keywordto
. 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 ofprotoc
and will now issue an error if there is no space between a numeric literal and subsequent identifier/keyword.
- The way
- The
protoc
compiler accepts'\v'
(vertical tab) and'\f'
(form feed) characters as whitespace, butprotoparse
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 thePrinter
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.