Documentation ¶
Overview ¶
Package pbinfo provides convenience types for looking up protobuf elements.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var GoTypeForPrim = map[descriptor.FieldDescriptorProto_Type]string{ descriptor.FieldDescriptorProto_TYPE_DOUBLE: "float64", descriptor.FieldDescriptorProto_TYPE_FLOAT: "float32", descriptor.FieldDescriptorProto_TYPE_INT64: "int64", descriptor.FieldDescriptorProto_TYPE_UINT64: "uint64", descriptor.FieldDescriptorProto_TYPE_INT32: "int32", descriptor.FieldDescriptorProto_TYPE_FIXED64: "uint64", descriptor.FieldDescriptorProto_TYPE_FIXED32: "uint32", descriptor.FieldDescriptorProto_TYPE_BOOL: "bool", descriptor.FieldDescriptorProto_TYPE_STRING: "string", descriptor.FieldDescriptorProto_TYPE_BYTES: "[]byte", descriptor.FieldDescriptorProto_TYPE_UINT32: "uint32", descriptor.FieldDescriptorProto_TYPE_SFIXED32: "int32", descriptor.FieldDescriptorProto_TYPE_SFIXED64: "int64", descriptor.FieldDescriptorProto_TYPE_SINT32: "int32", descriptor.FieldDescriptorProto_TYPE_SINT64: "int64", }
GoTypeForPrim maps protobuf primitive types to Go primitive types.
Functions ¶
func ReduceServName ¶
ReduceServName removes redundant components from the service name. For example, FooServiceV2 -> Foo. The returned name is used as part of longer names, like FooClient. If the package name and the service name is the same, ReduceServName returns empty string, so we get foo.Client instead of foo.FooClient.
Types ¶
type ImportSpec ¶
type ImportSpec struct {
Name, Path string
}
ImportSpec represents a Go module import path and an optional alias.
type Info ¶
type Info struct { // Maps services and messages to the file containing them, // so we can figure out the import. ParentFile map[proto.Message]*descriptor.FileDescriptorProto // Maps a protobuf element to the enclosing scope. // If enum E is defined in message M which is in file F, // ParentElement[E]=M, ParentElement[M]=nil, and ParentFile[M]=F ParentElement map[ProtoType]ProtoType // Maps type names to their messages. Type map[string]ProtoType // Maps service names to their descriptors. Serv map[string]*descriptor.ServiceDescriptorProto // PkgOverrides is file-to-import mapping used to override the // go_package option in the given proto file. PkgOverrides map[string]string }
Info provides lookup tables for various protobuf properties. For example, we can look up a type by name without iterating the entire descriptor.
func Of ¶
func Of(files []*descriptor.FileDescriptorProto) Info
Of creates Info from given protobuf files.
func (*Info) ImportSpec ¶
func (in *Info) ImportSpec(e ProtoType) (ImportSpec, error)
ImportSpec reports the ImportSpec for package containing protobuf element e. Deprecated: Use NameSpec instead.