luci: go.chromium.org/luci/common/proto/google/descutil Index | Files

package descutil

import "go.chromium.org/luci/common/proto/google/descutil"

Package descutil contains utility functions for protobuf descriptor messages.

Index

Package Files

doc.go generate.go tags.go util.go

Constants

const (
    // FileDescriptorProtoPackageTag is the number of package field
    // in FileDescriptorProto message.
    FileDescriptorProtoPackageTag = 2
    // FileDescriptorProtoMessageTag is the number of message field
    // in FileDescriptorProto message.
    FileDescriptorProtoMessageTag = 4
    // FileDescriptorProtoEnumTag is the number of enum field
    // in FileDescriptorProto message.
    FileDescriptorProtoEnumTag = 5
    // FileDescriptorProtoServiceTag is the number of service field
    // in FileDescriptorProto message.
    FileDescriptorProtoServiceTag = 6

    // ServiceDescriptorProtoMethodTag is the number of method field
    // in ServiceDescriptorProto message.
    ServiceDescriptorProtoMethodTag = 2

    // DescriptorProtoFieldTag is the number of field field
    // in DescriptorProto message.
    DescriptorProtoFieldTag = 2
    // DescriptorProtoNestedTypeTag is the number of nested_type field
    // in DescriptorProto message.
    DescriptorProtoNestedTypeTag = 3
    // DescriptorProtoEnumTypeTag is the number of enum_type field
    // in DescriptorProto message.
    DescriptorProtoEnumTypeTag = 4
    // DescriptorProtoOneOfTag is the number of oneof_decl field
    // in DescriptorProto message.
    DescriptorProtoOneOfTag = 8

    // EnumDescriptorProtoValueTag is the number of value field
    // in EnumDescriptorProto message.
    EnumDescriptorProtoValueTag = 2
)

These constnats correspond to tag values in the respective "descriptor.proto" message types. These constants' tag matches are asserted in the "TestTagsMatchProto" unit test.

func At Uses

func At(descProto proto.Message, path []int32) (interface{}, error)

At returns a descriptor proto or its field value at the given path. The path has same semantics as descriptor.SourceCodeInfo_Location.Path. See its comment for explanation.

For example, given a FileDescriptorProto and path [4, 2], At will return the 2nd top-level message DescriptorProto because 4 is FileDescriptorProto.MessageType field tag.

Does not supported uninterpreted options, returns (nil, nil).

func FindEnum Uses

func FindEnum(d *pb.DescriptorProto, name string) int

FindEnum searches for a nested EnumDescriptorProto by name.

func FindEnumForFile Uses

func FindEnumForFile(f *pb.FileDescriptorProto, name string) int

FindEnumForFile searches for an EnumDescriptorProto by name.

func FindEnumValue Uses

func FindEnumValue(e *pb.EnumDescriptorProto, name string) int

FindEnumValue searches for an EnumValueDescriptorProto by name.

func FindField Uses

func FindField(d *pb.DescriptorProto, name string) int

FindField searches for a FieldDescriptorProto by name.

func FindFile Uses

func FindFile(s *pb.FileDescriptorSet, name string) int

FindFile searches for a FileDescriptorProto by name.

func FindMessage Uses

func FindMessage(d *pb.DescriptorProto, name string) int

FindMessage searches for a nested DescriptorProto by name.

func FindMessageForFile Uses

func FindMessageForFile(f *pb.FileDescriptorProto, name string) int

FindMessageForFile searches for a DescriptorProto by name.

func FindMethodForService Uses

func FindMethodForService(s *pb.ServiceDescriptorProto, name string) int

FindMethodForService searches for a MethodDescriptorProto by name.

func FindOneOf Uses

func FindOneOf(d *pb.DescriptorProto, name string) int

FindOneOf searches for a nested OneofDescriptorProto by name.

func FindService Uses

func FindService(s *pb.FileDescriptorSet, fullName string) (file *pb.FileDescriptorProto, serviceIndex int)

FindService searches for a service by full name.

func FindServiceForFile Uses

func FindServiceForFile(f *pb.FileDescriptorProto, name string) int

FindServiceForFile searches for a FileDescriptorProto by name.

func FindValueByNumber Uses

func FindValueByNumber(e *pb.EnumDescriptorProto, number int32) int

FindValueByNumber searches for an EnumValueDescriptorProto by number.

func IndexSourceCodeInfo Uses

func IndexSourceCodeInfo(f *pb.FileDescriptorProto) (map[interface{}]*pb.SourceCodeInfo_Location, error)

IndexSourceCodeInfo returns a map that maps a pointer to the associated source code info, where the pointer points to a descriptor proto or its field, e.g. &myFieldDescriptorProto.Name.

IndexSourceCodeInfo can be used to retrieve comments.

Does not support whole-slice locations.

func Repeated Uses

func Repeated(f *pb.FieldDescriptorProto) bool

Repeated returns true if the field is repeated.

func Required Uses

func Required(f *pb.FieldDescriptorProto) bool

Required returns true if the field is required.

func Resolve Uses

func Resolve(s *pb.FileDescriptorSet, fullName string) (file *pb.FileDescriptorProto, obj interface{}, path []int)

Resolve searches for an object by full name. obj can be one of *ServiceDescriptorProto, *MethodDescriptorProto, *DescriptorProto, *FieldDescriptorProto, *DescriptorProto, *EnumDescriptorProto, *EnumValueDescriptorProto or nil

For path, see comment in SourceCodeInfo message.

Package descutil imports 6 packages (graph) and is imported by 6 packages. Updated 2018-10-24. Refresh now. Tools for package owners.