v2.0.0-beta.2
Pre-releaseThis is a pre-release for an upcoming v2.0.0 of this module.
Once we have more test coverage we'll create a proper release candidate, but for now we're considering this a "beta" of the next iteration of this repo.
(Note: there was also a v2.0.0-beta.1
tag, but it should be ignored, hence there being no release information associated with it.)
What's Changed?
A lot has changed!
This version finally drops the use of the old "v1 API" of the Protobuf Runtime for Go (github.com/golang/protobuf
) and instead is built on the current "v2 API": google.golang.org/protobuf
.
The v2 API introduced support for descriptors, reflection, and dynamic messages into the core runtime. That means several packages from v1 of this repo no longer exist.
Removed Packages
These packages were marked deprecated in v1.17.0. They have all been dropped for v2. See the list below for suitable replacements:
-
github.com/jhump/protoreflect/codec
If you're looking for a package to inspect or generate the Protobuf binary format, see google.golang.org/protobuf/encoding/protowire. -
github.com/jhump/protoreflect/desc
If you're looking to use descriptors, see google.golang.org/protobuf/reflect/protoreflect. If you're looking to create descriptors from descriptor protos (or vice versa), see google.golang.org/protobuf/reflect/protodesc. -
github.com/jhump/protoreflect/desc/protoparse
If you're looking to parse Protobuf source IDL and compile it into descriptors, see github.com/bufbuild/protocompile. -
github.com/jhump/protoreflect/dynamic
If you're looking for dynamic message capability, see google.golang.org/protobuf/types/dynamicpb. If you're looking for registries, for managing message and extension types to be used when unmarshaling message data, see google.golang.org/protobuf/reflect/protoregistry.
Renamed/Moved Packages
The other functionality in v1 of this module, the stuff that is retained in v2, has been moved around. Because the desc
and dynamic
directories were removed (since they were home to now-removed packages), most other packages have been shuffled around a little:
-
github.com/jhump/protoreflect/desc/builder => github.com/jhump/protoreflect/v2/protobuilder
-
github.com/jhump/protoreflect/desc/protoprint => github.com/jhump/protoreflect/v2/protoprint
-
github.com/jhump/protoreflect/desc/sourceinfo => github.com/jhump/protoreflect/v2/sourceinfo
(This includes thecmd/protoc-gen-gosrcinfo
command therein.) -
github.com/jhump/protoreflect/dynamic/grpcdynamic => github.com/jhump/protoreflect/v2/grpcdynamic
-
github.com/jhump/protoreflect/dynamic/msgregistry => github.com/jhump/protoreflect/v2/protoresolve/remotereg
This one has the most significant changes to its API. It now provides an interface compatible with types in the newgithub.com/jhump/protoreflect/v2/protoresolve
package. -
github.com/jhump/protoreflect/grpcreflect => github.com/jhump/protoreflect/v2/grpcreflect
(This one has not really been moved; the only difference in the import path is the obligatoryv2
component.)
New Packages
-
github.com/jhump/protoreflect/v2/protodescs
This package provides a few random helpers for working with descriptors and descriptor protos. -
github.com/jhump/protoreflect/v2/protomessage
This package provides some helpers for working with proto messages. -
github.com/jhump/protoreflect/v2/protoresolve
This package provides numerous nominal interface types for kinds of "resolvers". Resolvers are types that can answer queries about descriptors. This package also provides a*Registry
type, which builds on the standard API's*protoregistry.Files
and*protoregistry.Types
types and provides new functionality:- It is thread-safe and can be used from multiple goroutines.
- It can track the original descriptor proto from which a descriptor was built. This allows more convenient and efficient access than have to re-construct the descriptor proto (via the standard runtime's
protodesc
package). - It is a single value that can be used to query for descriptors as well as extension and message types. (The type implementations provided are all dynamic types.)
This package has the broadest new API and is the most likely to potentially change between this beta and a final v2.0.0 release.
-
github.com/jhump/protoreflect/v2/sourceloc
This package provides several helpers for working with instances ofprotoreflect.SourceLocation
andprotoreflect.SourcePath
.