Documentation ¶
Overview ¶
protoc-gen-goku Generator
Index ¶
- func RegisterData(data Data)
- func RegisterFunc(name string, function interface{})
- func RegisterFuncMap(funcMap FuncMap)
- func RegisterPlugin(p Plugin)
- func Run(STDIN io.Reader, STDOUT io.Writer, STDERR io.Writer)
- type Condition
- type Config
- type Context
- func (c *Context) Content() []byte
- func (c *Context) Data() Data
- func (c *Context) Enum() *descriptors.EnumDescriptorProto
- func (c *Context) Eval(text string, args ...interface{}) (string, error)
- func (c *Context) File() *descriptors.FileDescriptorProto
- func (c *Context) FuncMap() FuncMap
- func (c *Context) GetFileName() string
- func (c *Context) Loop() Loop
- func (c *Context) MergeData(data Data)
- func (c *Context) MergeFuncMap(funcMap FuncMap)
- func (c *Context) Message() *descriptors.DescriptorProto
- func (c *Context) Method() *descriptors.MethodDescriptorProto
- func (c *Context) MustEval(text string, args ...interface{}) string
- func (c *Context) Object() DescriptorObject
- func (c *Context) ParentMessage() *descriptors.DescriptorProto
- func (c *Context) PutValue(key interface{}, value interface{})
- func (c *Context) Service() *descriptors.ServiceDescriptorProto
- func (c *Context) SetContent(content []byte)
- func (c *Context) ShowFunc() string
- func (c *Context) Value(key interface{}) interface{}
- func (c *Context) WithLoop(loop Loop, desc DescriptorObject) *Context
- type Data
- type DescriptorObject
- type FuncMap
- type Generator
- func (g *Generator) Debug(format string, args ...interface{})
- func (g *Generator) Fatal(format string, args ...interface{})
- func (g *Generator) FatalOnErr(err error, format string, args ...interface{})
- func (g *Generator) GetDescriptorByName(typeName string) descriptors.ProtoType
- func (g *Generator) GetFileByName(protoFileName string) *descriptors.FileDescriptorProto
- func (g *Generator) GetObject(typeName string) descriptors.ProtoType
- func (g *Generator) MustGetDescriptorByName(typeName string) descriptors.ProtoType
- func (g *Generator) Param(key string, def string) string
- func (g *Generator) Recover(errPtr *error, msgs ...string)
- func (g *Generator) Run(IN io.Reader, OUT io.Writer, ERR io.Writer)
- func (g *Generator) ThrowsOnErr(err error)
- func (g *Generator) Value(key interface{}) interface{}
- func (g *Generator) Warn(format string, args ...interface{})
- func (g *Generator) WriteOutFile(filename string, content []byte) error
- type IfCondition
- type Job
- type Loop
- type LoopCondition
- type Plugin
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterPlugin ¶
func RegisterPlugin(p Plugin)
Types ¶
type Context ¶
type Context struct { *Generator // contains filtered or unexported fields }
func (*Context) Enum ¶
func (c *Context) Enum() *descriptors.EnumDescriptorProto
Enum ONLY [ LoopEnum ]
func (*Context) File ¶
func (c *Context) File() *descriptors.FileDescriptorProto
File returns current FileDescriptorProto
func (*Context) GetFileName ¶
func (*Context) MergeFuncMap ¶
func (*Context) Message ¶
func (c *Context) Message() *descriptors.DescriptorProto
Message ONLY [ LoopMessage ]
func (*Context) Method ¶
func (c *Context) Method() *descriptors.MethodDescriptorProto
Method returns current MethodDescriptorProto. ONLY [ LoopMethod ]
func (*Context) Object ¶
func (c *Context) Object() DescriptorObject
func (*Context) ParentMessage ¶
func (c *Context) ParentMessage() *descriptors.DescriptorProto
ParentMessage ONLY [ LoopNestedMessage LoopNestedEnum ]
func (*Context) Service ¶
func (c *Context) Service() *descriptors.ServiceDescriptorProto
Service returns current ServiceDescriptorProto. ONLY [ LoopService LoopMethod ]
func (*Context) SetContent ¶
type DescriptorObject ¶
type DescriptorObject interface { descriptors.DescriptorCommon GetName() string }
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
func NewGenerator ¶
func NewGenerator() *Generator
func (*Generator) FatalOnErr ¶
FatalOnErr 当 err!=nil 时报错并退出进程
func (*Generator) GetDescriptorByName ¶
func (g *Generator) GetDescriptorByName(typeName string) descriptors.ProtoType
通过protoc格式的名称 获取 proto 对象;
@param typeName .google.protobuf.FileDescriptorProto @return - message: *descriptorpb.DescriptorProto - enum: *descriptorpb.EnumDescriptorProto
func (*Generator) GetFileByName ¶
func (g *Generator) GetFileByName(protoFileName string) *descriptors.FileDescriptorProto
func (*Generator) MustGetDescriptorByName ¶
func (g *Generator) MustGetDescriptorByName(typeName string) descriptors.ProtoType
func (*Generator) ThrowsOnErr ¶
type IfCondition ¶
type IfCondition string
func (IfCondition) OK ¶
func (t IfCondition) OK(ctx *Context) bool
type Job ¶
type Job struct { // 任务名称 Name string // 根据所处阶段 Loop LoopCondition // 用户自定义的判断条件:返回 "true"/"false" // - 支持模版解析 If IfCondition // 模版内容 Template string // 模板路径 - 支持模板解析 // -- Template 为空时才会读取模板文件 TemplatePath string // 输出文件路径 Out string // 启用插件列表 // Plugins []string // 任务级别的变量 // - 与全局的 Config.Data Data Data }
func (Job) GetConditions ¶
type LoopCondition ¶
type LoopCondition []Loop
func (LoopCondition) OK ¶
func (t LoopCondition) OK(ctx *Context) bool
Click to show internal directories.
Click to hide internal directories.