Documentation ¶
Index ¶
- Constants
- func FieldDescriptorProtoLabelPrettyString(l descriptorpb.FieldDescriptorProto_Label) string
- func FieldDescriptorProtoTypePrettyString(t descriptorpb.FieldDescriptorProto_Type) string
- func FileDescriptorProtoForFileDescriptor(fileDescriptor FileDescriptor) *descriptorpb.FileDescriptorProto
- func FileDescriptorProtosForFileDescriptors[F FileDescriptor](fileDescriptors ...F) []*descriptorpb.FileDescriptorProto
- func FileDescriptorSetForFileDescriptors[F FileDescriptor](fileDescriptors ...F) *descriptorpb.FileDescriptorSet
- func ValidateFileDescriptor(fileDescriptor FileDescriptor) error
- func ValidateProtoPath(name string, path string) error
- func ValidateProtoPaths(name string, paths []string) error
- type FileDescriptor
Constants ¶
const ( // MinSupportedEdition is the earliest edition supported by this repo. MinSupportedEdition = descriptorpb.Edition_EDITION_2023 // MaxSupportedEdition is the latest edition supported by this repo. MaxSupportedEdition = descriptorpb.Edition_EDITION_2023 )
Variables ¶
This section is empty.
Functions ¶
func FieldDescriptorProtoLabelPrettyString ¶ added in v1.15.0
func FieldDescriptorProtoLabelPrettyString(l descriptorpb.FieldDescriptorProto_Label) string
FieldDescriptorProtoLabelPrettyString prints a pretty string representation of the FieldDescriptorProto_Label.
func FieldDescriptorProtoTypePrettyString ¶ added in v1.15.0
func FieldDescriptorProtoTypePrettyString(t descriptorpb.FieldDescriptorProto_Type) string
FieldDescriptorProtoTypePrettyString prints a pretty string representation of the FieldDescriptorProto_Type.
func FileDescriptorProtoForFileDescriptor ¶
func FileDescriptorProtoForFileDescriptor(fileDescriptor FileDescriptor) *descriptorpb.FileDescriptorProto
FileDescriptorProtoForFileDescriptor creates a new *descriptorpb.FileDescriptorProto for the fileDescriptor.
If the FileDescriptor is already a *descriptorpb.FileDescriptorProto, this returns the input value.
Note that this will not round trip exactly. If a *descriptorpb.FileDescriptorProto is turned into another object that is a FileDescriptor, and then passed to this function, the return value will not be equal if name, package, or syntax are set but empty. Instead, the return value will have these values unset. For our/most purposes, this is fine.
func FileDescriptorProtosForFileDescriptors ¶
func FileDescriptorProtosForFileDescriptors[F FileDescriptor](fileDescriptors ...F) []*descriptorpb.FileDescriptorProto
FileDescriptorProtosForFileDescriptors is a convenience function since Go does not have generics.
Note that this will not round trip exactly. If a *descriptorpb.FileDescriptorProto is turned into another object that is a FileDescriptor, and then passed to this function, the return value will not be equal if name, package, or syntax are set but empty. Instead, the return value will have these values unset. For our/most purposes, this is fine.
func FileDescriptorSetForFileDescriptors ¶
func FileDescriptorSetForFileDescriptors[F FileDescriptor](fileDescriptors ...F) *descriptorpb.FileDescriptorSet
FileDescriptorSetForFileDescriptors returns a new *descriptorpb.FileDescriptorSet for the given FileDescriptors.
Note that this will not round trip exactly. If a *descriptorpb.FileDescriptorProto is turned into another object that is a FileDescriptor, and then passed to this function, the return value will not be equal if name, package, or syntax are set but empty. Instead, the return value will have these values unset. For our/most purposes, this is fine.
func ValidateFileDescriptor ¶
func ValidateFileDescriptor(fileDescriptor FileDescriptor) error
ValidateFileDescriptor validates the FileDescriptor.
A *descriptorpb.FileDescriptorProto can be passed to this.
func ValidateProtoPath ¶
ValidateProtoPath validates the proto path.
This checks that the path is normalized and ends in .proto.
func ValidateProtoPaths ¶
ValidateProtoPaths validates the proto paths.
This checks that the paths are normalized and end in .proto.
Types ¶
type FileDescriptor ¶
type FileDescriptor interface { proto.Message GetName() string GetPackage() string GetDependency() []string GetPublicDependency() []int32 GetWeakDependency() []int32 GetMessageType() []*descriptorpb.DescriptorProto GetEnumType() []*descriptorpb.EnumDescriptorProto GetService() []*descriptorpb.ServiceDescriptorProto GetExtension() []*descriptorpb.FieldDescriptorProto GetOptions() *descriptorpb.FileOptions GetSourceCodeInfo() *descriptorpb.SourceCodeInfo GetSyntax() string GetEdition() descriptorpb.Edition }
FileDescriptor is an interface that matches the methods on a *descriptorpb.FileDescriptorProto.
Note that a FileDescriptor is not necessarily validated, unlike other interfaces in buf.