https://camo.githubusercontent.com/94dc67e5565e4119d2a72fe757cb9c774e4df1a173db51da16c91294f2db0ed2/68747470733a2f2f636972636c6563692e636f6d2f67682f6a68756d702f70726f746f7265666c6563742f747265652f76322e7376673f7374796c653d737667
https://camo.githubusercontent.com/43fef0457455507805c2a97671e72284b0a73fbda92b7efec9dbe4cded2ba132/68747470733a2f2f676f7265706f7274636172642e636f6d2f62616467652f6769746875622e636f6d2f6a68756d702f70726f746f7265666c656374
This repo builds on top of the reflection capabilities in the Protobuf runtime for Go and also provides reflection APIs for gRPC as well.
https://camo.githubusercontent.com/68e8c86c7317203dd564207bb836ecdf4c1dea05d109aa14a090db6132db507b/68747470733a2f2f706b672e676f2e6465762f62616467652f6769746875622e636f6d2f6a68756d702f70726f746f7265666c6563742f76322e737667
Note
Version 2.0.0 is still a work in progress. It is basically feature complete, but still needs more tests for the new functionality.
You can try it out by getting a pre-release version:
go get github.com/jhump/protoreflect/[email protected]
Note that the APIs may change a little bit between now and a final v2.0.0 release. Also note that some packages in v2 still need more tests, so you may find some bugs. But that should mostly be for new functionality. If you're just trying to update your code from v1 of this repo, those packages should be rock-solid and least likely to see any further API changes.
The protoreflect
package in the Protobuf Go runtime provides the Descriptor
interface and implementations of it that correspond to each of the descriptor types. These types are effectively smart wrappers around the generated Protobuf types in the descriptorpb
package. These wrappers make descriptors much more useful and easier to use.
This repo provides some additional packages for using and interacting with descriptors.
import "github.com/jhump/protoreflect/v2/protoprint"
The protoprint
package allows for printing of descriptors to .proto
source files. This is effectively the inverse of a parser/compiler (such as the protocompile
package.) Combined with the protobuilder
package, this is a useful tool for programmatically generating protocol buffer sources.
import "github.com/jhump/protoreflect/v2/protobuilder"
The protobuilder
package allows for programmatic construction of rich descriptors. Descriptors can be constructed programmatically by creating trees of descriptor protos and using the protodesc
package to link those into rich descriptors. But constructing a valid tree of descriptor protos is far from trivial.
So this package provides generous API to greatly simplify that task. It also allows for converting rich descriptors into builders, which means you can programmatically modify/tweak existing descriptors.