Documentation ¶
Index ¶
- func FilesToGenerate(req *plugin.CodeGeneratorRequest) ([]*descriptor.FileDescriptorProto, error)
- func RunProtocPlugin(g ProtocPlugin)
- type Descriptor
- type EnumDescriptor
- type ExtensionDescriptor
- type FileDescriptor
- type ImportedDescriptor
- type MethodDescriptor
- type Object
- type ProtocPlugin
- type ServiceDescriptor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FilesToGenerate ¶
func FilesToGenerate(req *plugin.CodeGeneratorRequest) ([]*descriptor.FileDescriptorProto, error)
FilesToGenerate is a helper to retrieve the set of FileDescriptorProtos targeted for generation, as opposed to the ones only included via imports.
func RunProtocPlugin ¶
func RunProtocPlugin(g ProtocPlugin)
RunProtocPlugin reads a protobuf generator request from standard in, runs the supplied generator, and writes its output to stdout. If an error occurs, the error will be printed to stderr, and the program will immediately exit with status code 1, so you should only call this at the end of your main function. This is the way protoc plugins interact with the protoc command.
Types ¶
type Descriptor ¶
type Descriptor struct { *descriptor.DescriptorProto Parent *Descriptor // The containing message, if any. // contains filtered or unexported fields }
Descriptor represents a protocol buffer message.
func (*Descriptor) File ¶
func (c *Descriptor) File() *descriptor.FileDescriptorProto
func (*Descriptor) TypeName ¶
func (d *Descriptor) TypeName() []string
TypeName returns the elements of the dotted type name. The package name is not part of this name.
type EnumDescriptor ¶
type EnumDescriptor struct { *descriptor.EnumDescriptorProto // contains filtered or unexported fields }
EnumDescriptor describes an enum. If it's at top level, its parent will be nil. Otherwise it will be the descriptor of the message in which it is defined.
func (*EnumDescriptor) File ¶
func (c *EnumDescriptor) File() *descriptor.FileDescriptorProto
func (*EnumDescriptor) TypeName ¶
func (e *EnumDescriptor) TypeName() (s []string)
TypeName returns the elements of the dotted type name. The package name is not part of this name.
type ExtensionDescriptor ¶
type ExtensionDescriptor struct { *descriptor.FieldDescriptorProto // contains filtered or unexported fields }
ExtensionDescriptor describes an extension. If it's at top level, its parent will be nil. Otherwise it will be the descriptor of the message in which it is defined.
func (*ExtensionDescriptor) DescName ¶
func (e *ExtensionDescriptor) DescName() string
DescName returns the variable name used for the generated descriptor.
func (*ExtensionDescriptor) File ¶
func (c *ExtensionDescriptor) File() *descriptor.FileDescriptorProto
func (*ExtensionDescriptor) TypeName ¶
func (e *ExtensionDescriptor) TypeName() (s []string)
TypeName returns the elements of the dotted type name. The package name is not part of this name.
type FileDescriptor ¶
type FileDescriptor struct { *descriptor.FileDescriptorProto Descriptors []*Descriptor // All the messages defined in this file. Enums []*EnumDescriptor // All the enums defined in this file. Extensions []*ExtensionDescriptor // All the top-level extensions defined in this file. Imported []*ImportedDescriptor // All types defined in files publicly imported by this file. Services []*ServiceDescriptor // All the services defined in this file. // Comments, stored as a map of path (comma-separated integers) to the comment. Comments map[string]*descriptor.SourceCodeInfo_Location Index int // The index of this file in the list of files to generate code for // contains filtered or unexported fields }
FileDescriptor describes an protocol buffer descriptor file (.proto). It includes slices of all the messages and enums defined within it. Those slices are constructed by WrapTypes.
func WrapTypes ¶
func WrapTypes(req *plugin.CodeGeneratorRequest) (genFiles, allFiles []*FileDescriptor, allFilesByName map[string]*FileDescriptor, err error)
WrapTypes walks the incoming data, wrapping DescriptorProtos, EnumDescriptorProtos and FileDescriptorProtos into file-referenced objects within the Generator. It also creates the list of files to generate and so should be called before GenerateAllFiles.
func (*FileDescriptor) BaseFileName ¶
func (d *FileDescriptor) BaseFileName() string
func (*FileDescriptor) PackageComments ¶
func (d *FileDescriptor) PackageComments() string
func (*FileDescriptor) VarName ¶
func (d *FileDescriptor) VarName() string
VarName is the variable name used in generated code to refer to the compressed bytes of this descriptor. It is not exported, so it is only valid inside the generated package.
protoc-gen-go writes its own version of this file, but so does protoc-gen-gogo - with a different name! Twirp aims to be compatible with both; the simplest way forward is to write the file descriptor again as another variable that we control.
type ImportedDescriptor ¶
type ImportedDescriptor struct { Object Object // contains filtered or unexported fields }
ImportedDescriptor describes a type that has been publicly imported from another file.
func (*ImportedDescriptor) File ¶
func (c *ImportedDescriptor) File() *descriptor.FileDescriptorProto
func (*ImportedDescriptor) TypeName ¶
func (id *ImportedDescriptor) TypeName() []string
type MethodDescriptor ¶
type MethodDescriptor struct { *descriptor.MethodDescriptorProto Path string // The SourceCodeInfo path as comma-separated integers. // contains filtered or unexported fields }
MethodDescriptor represents an RPC method on a protocol buffer service.
func (*MethodDescriptor) File ¶
func (c *MethodDescriptor) File() *descriptor.FileDescriptorProto
func (*MethodDescriptor) TypeName ¶
func (md *MethodDescriptor) TypeName() []string
type Object ¶
type Object interface { TypeName() []string File() *descriptor.FileDescriptorProto }
Object is an interface abstracting the abilities shared by enums, messages, extensions and imported objects.
type ProtocPlugin ¶
type ProtocPlugin interface {
Generate(in *plugin.CodeGeneratorRequest) (*plugin.CodeGeneratorResponse, error)
}
ProtocPlugin describes the interface for protoc-based code generators.
type ServiceDescriptor ¶
type ServiceDescriptor struct { *descriptor.ServiceDescriptorProto Methods []*MethodDescriptor Index int // index of the ServiceDescriptorProto in its parent FileDescriptorProto Path string // The SourceCodeInfo path as comma-separated integers. // contains filtered or unexported fields }
ServiceDescriptor represents a protocol buffer service.
func (*ServiceDescriptor) File ¶
func (c *ServiceDescriptor) File() *descriptor.FileDescriptorProto
func (*ServiceDescriptor) TypeName ¶
func (sd *ServiceDescriptor) TypeName() []string