Documentation ¶
Index ¶
- Constants
- func LoadFileDescriptorSet(filename string) (*pbprotos.FileDescriptorSet, error)
- type CommentMeta
- type CommentParser
- type Descriptor
- func (self *Descriptor) Contains(fd *FieldDescriptor) bool
- func (self *Descriptor) Field(index int) *FieldDescriptor
- func (self *Descriptor) FieldByName(name string) *FieldDescriptor
- func (self *Descriptor) FieldByNumber(number int32) *FieldDescriptor
- func (self *Descriptor) FieldCount() int
- func (self *Descriptor) Name() string
- type DescriptorPool
- func (self *DescriptorPool) EnumByFullName(fullname string) *EnumDescriptor
- func (self *DescriptorPool) File(index int) *FileDescriptor
- func (self *DescriptorPool) FileByName(name string) *FileDescriptor
- func (self *DescriptorPool) FileCount() int
- func (self *DescriptorPool) MessageByFullName(fullname string) *Descriptor
- type EnumDescriptor
- func (self *EnumDescriptor) Name() string
- func (self *EnumDescriptor) String() string
- func (self *EnumDescriptor) Value(index int) *EnumValueDescriptor
- func (self *EnumDescriptor) ValueByName(name string) *EnumValueDescriptor
- func (self *EnumDescriptor) ValueByNumber(number int32) *EnumValueDescriptor
- func (self *EnumDescriptor) ValueCount() int
- type EnumSet
- type EnumValueDescriptor
- type FieldDescriptor
- func (self *FieldDescriptor) DefaultValue() string
- func (self *FieldDescriptor) EnumDesc() *EnumDescriptor
- func (self *FieldDescriptor) FullTypeName() string
- func (self *FieldDescriptor) IsEnumType() bool
- func (self *FieldDescriptor) IsMessageType() bool
- func (self *FieldDescriptor) IsOptional() bool
- func (self *FieldDescriptor) IsRepeated() bool
- func (self *FieldDescriptor) IsRequired() bool
- func (self *FieldDescriptor) Label() pbprotos.FieldDescriptorProto_Label
- func (self *FieldDescriptor) MessageDesc() *Descriptor
- func (self *FieldDescriptor) Name() string
- func (self *FieldDescriptor) Type() pbprotos.FieldDescriptorProto_Type
- func (self *FieldDescriptor) TypeName() string
- type FileDescriptor
- type MessageSet
- type TaggedComment
Constants ¶
View Source
const ( Token_EOF = iota Token_LeftBrace Token_RightBrace Token_WhiteSpace Token_LineEnd Token_UnixStyleComment Token_Identifier Token_Unknown )
自定义的token id
Variables ¶
This section is empty.
Functions ¶
func LoadFileDescriptorSet ¶
func LoadFileDescriptorSet(filename string) (*pbprotos.FileDescriptorSet, error)
文件格式必须是由protoc-gen-meta输出的CodeGeneratorRequest格式
Types ¶
type CommentMeta ¶
type CommentMeta struct {
// contains filtered or unexported fields
}
func (*CommentMeta) FindTaggedComment ¶
func (self *CommentMeta) FindTaggedComment(name string) (string, bool)
func (*CommentMeta) LeadingComment ¶
func (self *CommentMeta) LeadingComment() string
func (*CommentMeta) ParseTaggedComment ¶
func (self *CommentMeta) ParseTaggedComment() []*TaggedComment
解析带有tag的comment, 类似于go结构体中的命名tag
func (*CommentMeta) TrailingComment ¶
func (self *CommentMeta) TrailingComment() string
type CommentParser ¶
func NewCommentParser ¶
func NewCommentParser(srcName string) *CommentParser
func (*CommentParser) Run ¶
func (self *CommentParser) Run(src string, commentArray []*TaggedComment) (ret []*TaggedComment)
type Descriptor ¶
type Descriptor struct { Define *pbprotos.DescriptorProto EnumSet // 内嵌枚举 CommentMeta NestedMsg MessageSet // 内嵌结构 // contains filtered or unexported fields }
func (*Descriptor) Contains ¶
func (self *Descriptor) Contains(fd *FieldDescriptor) bool
func (*Descriptor) Field ¶
func (self *Descriptor) Field(index int) *FieldDescriptor
func (*Descriptor) FieldByName ¶
func (self *Descriptor) FieldByName(name string) *FieldDescriptor
func (*Descriptor) FieldByNumber ¶
func (self *Descriptor) FieldByNumber(number int32) *FieldDescriptor
func (*Descriptor) FieldCount ¶
func (self *Descriptor) FieldCount() int
func (*Descriptor) Name ¶
func (self *Descriptor) Name() string
type DescriptorPool ¶
type DescriptorPool struct {
// contains filtered or unexported fields
}
func CreatePoolByFile ¶
func CreatePoolByFile(filename string) (*DescriptorPool, error)
根据文件描述符创建描述池
func NewDescriptorPool ¶
func NewDescriptorPool(fds *pbprotos.FileDescriptorSet) *DescriptorPool
func (*DescriptorPool) EnumByFullName ¶
func (self *DescriptorPool) EnumByFullName(fullname string) *EnumDescriptor
通过全名取枚举
func (*DescriptorPool) FileByName ¶
func (self *DescriptorPool) FileByName(name string) *FileDescriptor
获取文件描述符
func (*DescriptorPool) MessageByFullName ¶
func (self *DescriptorPool) MessageByFullName(fullname string) *Descriptor
通过全名取消息
type EnumDescriptor ¶
type EnumDescriptor struct { Define *pbprotos.EnumDescriptorProto CommentMeta // contains filtered or unexported fields }
func (*EnumDescriptor) Name ¶
func (self *EnumDescriptor) Name() string
func (*EnumDescriptor) String ¶
func (self *EnumDescriptor) String() string
func (*EnumDescriptor) Value ¶
func (self *EnumDescriptor) Value(index int) *EnumValueDescriptor
func (*EnumDescriptor) ValueByName ¶
func (self *EnumDescriptor) ValueByName(name string) *EnumValueDescriptor
func (*EnumDescriptor) ValueByNumber ¶
func (self *EnumDescriptor) ValueByNumber(number int32) *EnumValueDescriptor
func (*EnumDescriptor) ValueCount ¶
func (self *EnumDescriptor) ValueCount() int
type EnumSet ¶
type EnumSet struct {
// contains filtered or unexported fields
}
func (*EnumSet) Enum ¶
func (self *EnumSet) Enum(index int) *EnumDescriptor
func (*EnumSet) EnumByName ¶
func (self *EnumSet) EnumByName(name string) *EnumDescriptor
func (*EnumSet) EnumValueByName ¶
func (self *EnumSet) EnumValueByName(name string) *EnumValueDescriptor
type EnumValueDescriptor ¶
type EnumValueDescriptor struct { Define *pbprotos.EnumValueDescriptorProto CommentMeta }
func (*EnumValueDescriptor) Name ¶
func (self *EnumValueDescriptor) Name() string
func (*EnumValueDescriptor) Value ¶
func (self *EnumValueDescriptor) Value() int32
type FieldDescriptor ¶
type FieldDescriptor struct { Define *pbprotos.FieldDescriptorProto CommentMeta // contains filtered or unexported fields }
func (*FieldDescriptor) DefaultValue ¶
func (self *FieldDescriptor) DefaultValue() string
func (*FieldDescriptor) EnumDesc ¶
func (self *FieldDescriptor) EnumDesc() *EnumDescriptor
func (*FieldDescriptor) FullTypeName ¶
func (self *FieldDescriptor) FullTypeName() string
pb定义中插件返回的格式时 .package.type.value的格式, 这里返回去掉头的.
func (*FieldDescriptor) IsEnumType ¶
func (self *FieldDescriptor) IsEnumType() bool
func (*FieldDescriptor) IsMessageType ¶
func (self *FieldDescriptor) IsMessageType() bool
func (*FieldDescriptor) IsOptional ¶
func (self *FieldDescriptor) IsOptional() bool
func (*FieldDescriptor) IsRepeated ¶
func (self *FieldDescriptor) IsRepeated() bool
func (*FieldDescriptor) IsRequired ¶
func (self *FieldDescriptor) IsRequired() bool
func (*FieldDescriptor) Label ¶
func (self *FieldDescriptor) Label() pbprotos.FieldDescriptorProto_Label
func (*FieldDescriptor) MessageDesc ¶
func (self *FieldDescriptor) MessageDesc() *Descriptor
func (*FieldDescriptor) Name ¶
func (self *FieldDescriptor) Name() string
func (*FieldDescriptor) Type ¶
func (self *FieldDescriptor) Type() pbprotos.FieldDescriptorProto_Type
func (*FieldDescriptor) TypeName ¶
func (self *FieldDescriptor) TypeName() string
type FileDescriptor ¶
type FileDescriptor struct { Define *pbprotos.FileDescriptorProto EnumSet MessageSet // contains filtered or unexported fields }
func (*FileDescriptor) Comment ¶
func (self *FileDescriptor) Comment(path string) *pbprotos.SourceCodeInfo_Location
func (*FileDescriptor) FileName ¶
func (self *FileDescriptor) FileName() string
func (*FileDescriptor) PackageName ¶
func (self *FileDescriptor) PackageName() string
type MessageSet ¶
type MessageSet struct {
// contains filtered or unexported fields
}
func (*MessageSet) DebugPrint ¶
func (self *MessageSet) DebugPrint()
func (*MessageSet) Message ¶
func (self *MessageSet) Message(index int) *Descriptor
func (*MessageSet) MessageByName ¶
func (self *MessageSet) MessageByName(name string) *Descriptor
func (*MessageSet) MessageCount ¶
func (self *MessageSet) MessageCount() int
type TaggedComment ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.