Documentation
¶
Index ¶
- func NewProtocPlugin() func(gen *protogen.Plugin) error
- type Enum
- type EnumValue
- type Field
- type FileInfo
- type Generator
- type HTTPRule
- type Message
- func (mi Message) FieldWithFileTag() []Field
- func (mi Message) FieldWithFormTag() []Field
- func (mi Message) FieldWithHeaderTag() []Field
- func (mi Message) FieldWithJSONTag() []Field
- func (mi Message) FieldWithPathTag() []Field
- func (mi Message) FieldWithQueryTag() []Field
- func (mi Message) FieldWithTag(tagName string) []Field
- func (mi Message) HasFile() bool
- func (mi Message) HasFormParam() bool
- func (mi Message) HasHeaderParam() bool
- func (mi Message) HasQueryParam() bool
- func (mi Message) P()
- func (mi Message) QueryFieldByTagKeyAndValue(key, value string) (Field, bool)
- type Method
- type ProtocPlugin
- type Service
- type Tag
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewProtocPlugin ¶
NewProtocPlugin new protoc plugin
Types ¶
type Enum ¶
type Enum struct { GoIdent string // name of the generated Go type: the enum's name LeadingComments string Values []EnumValue // contains filtered or unexported fields }
Enum describes an enum.
type EnumValue ¶
type EnumValue struct { LeadingComments string TrailingComment string ShortName string // the short name of the declaration GoIdent string // name of the generated Go type Type string // Go type Number int32 // the enum value as an integer. }
EnumValue represents a enum value.
type Field ¶
type Field struct { GoName string // filed name GoType string // field type, e.g int32, string, bool LeadingComments string Tags []*Tag }
Field describes field in structure.
func (Field) TagByValue ¶
TagByValue finds tag by value.
type FileInfo ¶
type FileInfo struct { *protogen.File AllMessages []*protogen.Message AllEnums []*protogen.Enum AllService []*protogen.Service }
FileInfo file info
func NewFileInfo ¶
NewFileInfo constructs then file info.
type Message ¶
type Message struct { GoName string LeadingComments string // leading comments Fields []Field // all fields // contains filtered or unexported fields }
Message describes the message.
func NewMessage ¶
func NewMessage(f *protogen.GeneratedFile, m *protogen.Message) *Message
NewMessage new message info
func (Message) FieldWithFileTag ¶
FieldWithFileTag returns all fields that have tag `file`.
func (Message) FieldWithFormTag ¶
FieldWithFormTag returns all fields that have tag `form`.
func (Message) FieldWithHeaderTag ¶
FieldWithHeaderTag returns all fields that have tag `header`.
func (Message) FieldWithJSONTag ¶
FieldWithJSONTag returns all fields that have tag `json`.
func (Message) FieldWithPathTag ¶
FieldWithPathTag returns all fields that have tag `path`.
func (Message) FieldWithQueryTag ¶
FieldWithQueryTag returns all fields that have tag `query`.
func (Message) FieldWithTag ¶
FieldWithTag returns all fileds that has specified tag.
func (Message) HasFormParam ¶
HasFormParam returns true if there is at least one form param.
func (Message) HasHeaderParam ¶
HasHeaderParam returns true if there is at least one header param.
func (Message) HasQueryParam ¶
HasQueryParam returns true if there is at least one query param.
type Method ¶
type Method struct { Name string Request *Message Response *Message HTTPRules []*HTTPRule Comments string }
Method service's method
func (Method) HasHTTPRules ¶
func (Method) HasPathParam ¶
HasPathParam returns true if there is at least one http rule contains path param.
type ProtocPlugin ¶
type ProtocPlugin struct {
// contains filtered or unexported fields
}
ProtocPlugin is a plugin used to generate service implementation
func (*ProtocPlugin) Execute ¶
func (p *ProtocPlugin) Execute() (err error)
Execute starts to generate file.
func (*ProtocPlugin) GenerateFile ¶
func (p *ProtocPlugin) GenerateFile(file *FileInfo)
GenerateFile generates file.