Documentation ¶
Index ¶
- type Comments
- type Data
- func (d *Data) EnumValues() EnumValueSlice
- func (d *Data) Enums() EnumSlice
- func (d *Data) Fields() FieldSlice
- func (d *Data) Files() FileSlice
- func (d *Data) Messages() MessageSlice
- func (d *Data) Methods() MethodSlice
- func (d *Data) Oneofs() OneofSlice
- func (d *Data) PackagesToGenerate() []string
- func (d *Data) Services() ServiceSlice
- type Enum
- type EnumSlice
- type EnumValue
- type EnumValueSlice
- type Field
- func (f Field) IsDeprecated() bool
- func (f Field) IsOneof() bool
- func (f Field) IsRepeated() bool
- func (f Field) IsTypeBool() bool
- func (f Field) IsTypeBytes() bool
- func (f Field) IsTypeDouble() bool
- func (f Field) IsTypeEnum() bool
- func (f Field) IsTypeFixed32() bool
- func (f Field) IsTypeFixed64() bool
- func (f Field) IsTypeFloat() bool
- func (f Field) IsTypeGroup() bool
- func (f Field) IsTypeInt32() bool
- func (f Field) IsTypeInt64() bool
- func (f Field) IsTypeMessage() bool
- func (f Field) IsTypeSfixed32() bool
- func (f Field) IsTypeSfixed64() bool
- func (f Field) IsTypeSint32() bool
- func (f Field) IsTypeSint64() bool
- func (f Field) IsTypeString() bool
- func (f Field) IsTypeUint32() bool
- func (f Field) IsTypeUint64() bool
- func (f Field) IsVisible() bool
- func (f Field) Oneof() *Oneof
- func (f Field) Parent() Message
- func (f Field) String() string
- func (f Field) TypeEnum() *Enum
- func (f Field) TypeMessage() *Message
- func (f Field) TypeNameString() string
- type FieldSlice
- type File
- type FileSlice
- type Message
- func (m Message) Enums() EnumSlice
- func (m Message) Fields() FieldSlice
- func (m Message) File() File
- func (m Message) IsDeprecated() bool
- func (m Message) IsNested() bool
- func (m Message) IsVisible() bool
- func (m Message) Messages() MessageSlice
- func (m Message) Oneofs() OneofSlice
- func (m Message) Parent() *Message
- func (m Message) Root() Message
- func (m Message) String() string
- type MessageSlice
- type Method
- type MethodSlice
- type Oneof
- type OneofSlice
- type Service
- type ServiceSlice
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Data ¶
type Data struct {
// contains filtered or unexported fields
}
Data is type assigned to "dot" when evaluating templates
func New ¶
func New(req *plugin.CodeGeneratorRequest) *Data
New returns a new Data describing the code generator request
func (*Data) EnumValues ¶
func (d *Data) EnumValues() EnumValueSlice
EnumValues returns a slice of defined enum values
func (*Data) Messages ¶
func (d *Data) Messages() MessageSlice
Messages returns a slice of defined messages
func (*Data) Methods ¶
func (d *Data) Methods() MethodSlice
Methods returns a slice of defined methods
func (*Data) PackagesToGenerate ¶
PackagesToGenerate returns a slice containing all package names used in files to generate
func (*Data) Services ¶
func (d *Data) Services() ServiceSlice
Services returns a slice of defined services
type Enum ¶
type Enum struct { Name string Meta meta.EnumMetadata // Custom metadata extensions defined for protoc-gen-template Options descriptor.EnumOptions // Globally-defined enum metadata Comments Comments // contains filtered or unexported fields }
Enum describes a protobuf enum
func (Enum) IsDeprecated ¶
IsDeprecated returns true if the enumeration's file or any enclosing messages are deprecated, or if its deprecation option is true
func (Enum) IsVisible ¶
IsVisible returns true if the enumeration's file and any enclosing messages are visibile and its visibility metadata is `PUBLIC`
func (Enum) Values ¶
func (e Enum) Values() EnumValueSlice
Values returns a slice of the enum's values
type EnumSlice ¶
type EnumSlice []Enum
EnumSlice is a slice of enums
func (EnumSlice) NotDeprecated ¶
NotDeprecated returns the non-deprecated values in the slice
func (EnumSlice) ToGenerate ¶
ToGenerate returns the values in the slice defined in files to be generated
type EnumValue ¶
type EnumValue struct { Name string Meta meta.EnumValueMetadata // Custom metadata extensions defined for protoc-gen-template Options descriptor.EnumValueOptions // Globally-defined enum value metadata Comments Comments Number int32 // contains filtered or unexported fields }
EnumValue describes a protobuf enum value
func (EnumValue) IsDeprecated ¶
IsDeprecated returns true if the enumeration value's parent is deprecated or its deprecation option is true
func (EnumValue) IsVisible ¶
IsVisible returns true if the enumeration value's parent is visible and its visibility metadata is `PUBLIC`
type EnumValueSlice ¶
type EnumValueSlice []EnumValue
EnumValueSlice is a slice of enum values
func (EnumValueSlice) NotDeprecated ¶
func (s EnumValueSlice) NotDeprecated() EnumValueSlice
NotDeprecated returns the non-deprecated values in the slice
func (EnumValueSlice) Visible ¶
func (s EnumValueSlice) Visible() EnumValueSlice
Visible returns the visible values in the slice
type Field ¶
type Field struct { Name string Meta meta.FieldMetadata // Custom metadata extensions defined for protoc-gen-template Options descriptor.FieldOptions // Globally-defined field metadata Comments Comments Number int32 Label descriptor.FieldDescriptorProto_Label Type descriptor.FieldDescriptorProto_Type // For numeric types, contains the original text representation of the value. // For booleans, "true" or "false". // For strings, contains the default text contents (not escaped in any way). // For bytes, contains the C escaped value. All bytes >= 128 are escaped. // TODO(kenton): Base-64 encode? DefaultValue string // JSON name of this field. The value is set by protocol compiler. If the // user has set a "json_name" option on this field, that option's value // will be used. Otherwise, it's deduced from the field's name by converting // it to camelCase. JSONName string // contains filtered or unexported fields }
Field describes a protobuf message field
func (Field) IsDeprecated ¶
IsDeprecated returns true if the field's parent or type are deprecated or if its deprecation option is true
func (Field) IsRepeated ¶
IsRepeated is true if the field's label is 'REPEATED'
func (Field) IsTypeBool ¶
IsTypeBool is true if the field's type is 'bool'
func (Field) IsTypeBytes ¶
IsTypeBytes is true if the field's type is 'bytes'
func (Field) IsTypeDouble ¶
IsTypeDouble is true if the field's type is 'double'
func (Field) IsTypeEnum ¶
IsTypeEnum is true if the field's type is an enum
func (Field) IsTypeFixed32 ¶
IsTypeFixed32 is true if the field's type is 'fixed32'
func (Field) IsTypeFixed64 ¶
IsTypeFixed64 is true if the field's type is 'fixed64'
func (Field) IsTypeFloat ¶
IsTypeFloat is true if the field's type is 'float'
func (Field) IsTypeGroup ¶
IsTypeGroup is true if the field's type is 'group'
func (Field) IsTypeInt32 ¶
IsTypeInt32 is true if the field's type is 'int32'
func (Field) IsTypeInt64 ¶
IsTypeInt64 is true if the field's type is 'int64'
func (Field) IsTypeMessage ¶
IsTypeMessage is true if the field's type is a message
func (Field) IsTypeSfixed32 ¶
IsTypeSfixed32 is true if the field's type is 'sfixed32'
func (Field) IsTypeSfixed64 ¶
IsTypeSfixed64 is true if the field's type is 'sfixed64'
func (Field) IsTypeSint32 ¶
IsTypeSint32 is true if the field's type is 'sint32'
func (Field) IsTypeSint64 ¶
IsTypeSint64 is true if the field's type is 'sint64'
func (Field) IsTypeString ¶
IsTypeString is true if the field's type is 'string'
func (Field) IsTypeUint32 ¶
IsTypeUint32 is true if the field's type is 'uint32'
func (Field) IsTypeUint64 ¶
IsTypeUint64 is true if the field's type is 'uint64'
func (Field) IsVisible ¶
IsVisible returns true if the field's parent and type is visible and its visibility metadata `PUBLIC`
func (Field) TypeMessage ¶
TypeMessage returns the message type if the field is message-typed, else nil
func (Field) TypeNameString ¶
TypeNameString returns a prettified string descripton of a field's type
Examples:
{Type: "TYPE_STRING", TypeName: nil, Label: OPTIONAL} -> "string" {Type: "TYPE_STRING", TypeName: nil, Label: REQUIRED} -> "string" {Type: "TYPE_STRING", TypeName: nil, Label: REPEATED} -> "[]string" {Type: "TYPE_BYTES", TypeName: nil, Label: REPEATED} -> "bytes" {Type: "TYPE_MESSAGE", TypeName: ".pkg.Msg, Label: OPTIONAL} -> "pkg.Msg" {Type: "TYPE_ENUM", TypeName: ".pkg.Enm, Label: OPTIONAL} -> "pkg.Enm"
type FieldSlice ¶
type FieldSlice []Field
FieldSlice is a slice of fields
func (FieldSlice) NotDeprecated ¶
func (s FieldSlice) NotDeprecated() FieldSlice
NotDeprecated returns the non-deprecated values in the slice
func (FieldSlice) Visible ¶
func (s FieldSlice) Visible() FieldSlice
Visible returns the visible values in the slice
type File ¶
type File struct { Package string Name string Comments Comments Meta meta.FileMetadata // Custom metadata extensions defined for protoc-gen-template Options descriptor.FileOptions // Globally-defined file metadata Generate bool // Generate is true if the file is included in FileToGenerate Dependencies []string // Dependencies lists the names of files imported by this file. Syntax string // Syntax is of the proto file - proto2/proto3 // contains filtered or unexported fields }
File describes a protobuf source file
func (File) GoPackageImport ¶
GoPackageImport returns the go import path for the file's package
- If the file's GoPackage option is set and contains the `;` character, returns any content before the character
- If the file's GoPackage options is set and doesn't contain the `;` character, returns the GoPackage value
- Returns the directory portion of the file's Name value
- Returns the file's Name value
func (File) GoPackageName ¶
GoPackageName returns a package name for importing the file:
- If the file's GoPackage option is set and contains the `;` character, returns any content after the character
- If the file's GoPackage options is set and doesn't contain the `;` character, returns the basename portion of the GoPackage value
- Returns the basename portion of file's Name value
func (File) IsDeprecated ¶
IsDeprecated returns true if the file's deprecation option is true
func (File) Messages ¶
func (f File) Messages() MessageSlice
Messages returns a slice of the file's messages
func (File) Services ¶
func (f File) Services() ServiceSlice
Services returns a slice of the file's services
type FileSlice ¶
type FileSlice []File
FileSlice is a slice of files
func (FileSlice) NotDeprecated ¶
NotDeprecated returns the non-deprecated values in the slice
func (FileSlice) ToGenerate ¶
ToGenerate returns the values in the slice to be generated
type Message ¶
type Message struct { Name string Meta meta.MessageMetadata // Custom metadata extensions defined for protoc-gen-template Options descriptor.MessageOptions // Globally-defined message metadata Comments Comments ReservedTags []descriptor.DescriptorProto_ReservedRange ReservedNames []string // Reserved field names, which may not be used by fields in the same message. // contains filtered or unexported fields }
Message describes a protobuf message definition
func (Message) Fields ¶
func (m Message) Fields() FieldSlice
Fields returns a slice of the message's fields
func (Message) IsDeprecated ¶
IsDeprecated returns true if the message's file or any enclosing messages are deprecated, or if its deprecation option is true
func (Message) IsVisible ¶
IsVisible returns true if the message's file and any enclosing message are visible, and its visibility metadata is `PUBLIC`
func (Message) Messages ¶
func (m Message) Messages() MessageSlice
Messages returns a slice of nested messages
func (Message) Oneofs ¶
func (m Message) Oneofs() OneofSlice
Oneofs returns a slice of the message's oneofs
type MessageSlice ¶
type MessageSlice []Message
MessageSlice is a slice of messages
func (MessageSlice) NotDeprecated ¶
func (s MessageSlice) NotDeprecated() MessageSlice
NotDeprecated returns the non-deprecated values in the slice
func (MessageSlice) NotNested ¶
func (s MessageSlice) NotNested() MessageSlice
NotNested returns the non-nested values in the slice
func (MessageSlice) ToGenerate ¶
func (s MessageSlice) ToGenerate() MessageSlice
ToGenerate returns the values in the slice defined in files to be generated
func (MessageSlice) Visible ¶
func (s MessageSlice) Visible() MessageSlice
Visible returns the visible values in the slice
type Method ¶
type Method struct { Name string Meta meta.MethodMetadata // Custom metadata extensions defined for protoc-gen-template Options descriptor.MethodOptions // Globally-defined service metadata Comments Comments ClientStreaming bool ServerStreaming bool // contains filtered or unexported fields }
Method describes a protobuf service method
func (Method) IsDeprecated ¶
IsDeprecated returns true if the method's service or any of its input/output messages are deprecated, or its deprecation option is true
func (Method) IsVisible ¶
IsVisible returns true if the method's service and its input/output messages are visible, and its visibility metadata is `PUBLIC`
func (Method) OutputType ¶
OutputType returns the method's output type
type MethodSlice ¶
type MethodSlice []Method
MethodSlice is a slice of methods
func (MethodSlice) NotDeprecated ¶
func (s MethodSlice) NotDeprecated() MethodSlice
NotDeprecated returns the non-deprecated values in the slice
func (MethodSlice) Visible ¶
func (s MethodSlice) Visible() MethodSlice
Visible returns the visible values in the slice
type Oneof ¶
type Oneof struct { Name string Options descriptor.OneofOptions // Globally-defined message metadata Comments Comments // contains filtered or unexported fields }
Oneof describes a protobuf message definition
func (Oneof) Fields ¶
func (o Oneof) Fields() FieldSlice
Fields returns a slice of the oneof's fields
func (Oneof) IsDeprecated ¶
IsDeprecated returns true if the oneof's parent message is deprecated
type OneofSlice ¶
type OneofSlice []Oneof
OneofSlice is a slice of oneofs
func (OneofSlice) NotDeprecated ¶
func (s OneofSlice) NotDeprecated() OneofSlice
NotDeprecated returns the non-deprecated values in the slice
func (OneofSlice) Visible ¶
func (s OneofSlice) Visible() OneofSlice
Visible returns the visible values in the slice
type Service ¶
type Service struct { Name string Meta meta.ServiceMetadata // Custom metadata extensions defined for protoc-gen-template Options descriptor.ServiceOptions // Globally-defined service metadata Comments Comments // contains filtered or unexported fields }
Service describes a protobuf service
func (Service) IsDeprecated ¶
IsDeprecated returns true if the service's file is deprecated or its deprecation option is true
func (Service) IsVisible ¶
IsVisible returns true if the service's file is visible and its visibility metadata is `PUBLIC`
func (Service) Methods ¶
func (s Service) Methods() MethodSlice
Methods returns a slice of the service's methods
type ServiceSlice ¶
type ServiceSlice []Service
ServiceSlice is a slice of services
func (ServiceSlice) NotDeprecated ¶
func (s ServiceSlice) NotDeprecated() ServiceSlice
NotDeprecated returns the non-deprecated values in the slice
func (ServiceSlice) ToGenerate ¶
func (s ServiceSlice) ToGenerate() ServiceSlice
ToGenerate returns the values in the slice defined in files to be generated
func (ServiceSlice) Visible ¶
func (s ServiceSlice) Visible() ServiceSlice
Visible returns the visible values in the slice