Documentation ¶
Overview ¶
golang plugin
Index ¶
- func IsGoKeyword(s string) bool
- func IsGoPredeclaredIdentifier(s string) bool
- func Throws(err error)
- type Context
- func (c Context) FileGoPackage(file *descriptors.FileDescriptorProto) *GoPackage
- func (c Context) FuncMap() goku.FuncMap
- func (c Context) GoComments(arg interface{}) string
- func (c Context) GoImport(arg interface{}) string
- func (c Context) GoImportDependency(arg interface{}) string
- func (c Context) GoMarkImport(v interface{}) interface{}
- func (c Context) GoPackage(value interface{}) *GoPackage
- func (c Context) GoType(value interface{}) *GoType
- func (c Context) GoTypeBase(v interface{}) string
- func (c Context) PbField2GoType(field *descriptors.FieldDescriptorProto) *GoType
- func (c Context) PbType2GoType(pbType descriptors.ProtoType) *GoType
- func (c Context) RegisterPackage(pkg string, name string) *GoPackage
- type GoFormatter
- type GoPackage
- type GoType
- func (t *GoType) Copy() *GoType
- func (t *GoType) FormatPipeline(args helper.Args) (string, error)
- func (t *GoType) Import() string
- func (t *GoType) Name() string
- func (t *GoType) Package() *GoPackage
- func (t *GoType) SetField(field string, value interface{}) *GoType
- func (t *GoType) SetPackage(value interface{}) *GoType
- func (t *GoType) SetPipeline(field string, value interface{}) interface{}
- func (t *GoType) SetPointer(value interface{}) *GoType
- func (t *GoType) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsGoKeyword ¶
Types ¶
type Context ¶
golang 对context提供的处理函数集合 其他基于 golang 的插件可以继承此类进行扩展
func NewContext ¶
func (Context) FileGoPackage ¶
func (c Context) FileGoPackage(file *descriptors.FileDescriptorProto) *GoPackage
File to GoPackage
func (Context) GoComments ¶
GoComments returns golang style comments string
supported arg: - string - []string - descriptors.DescriptorCommon - descriptors.SourceCodeInfo_Location
func (Context) GoImportDependency ¶
GoImportDependency returns golang style import lines for file Dependency
func (Context) GoMarkImport ¶
func (c Context) GoMarkImport(v interface{}) interface{}
GoMarkImport 标记导入 【v】 所在的包,并在最终生成代码时加入到 import 中
v: 能转化为 GoPackage 的对象,并且没有对【v】做任何修改,直接返回.
所以 GoMarkImport 可以放在 pipeline 的任意合适的位置(前一个pipeline必须返回【v】)
而 GoImport 必须放在 import 括号之中(直接生成了字符串) 还有 GoImportDependency 也必须放在 import 括号之中,但是副作用很大,
因为会导入proto文件中声明的所有 import,虽然最后生成代码时会自动 clean unused import.
Example: {{$Input:=$Method.InputType|GoType|GoMarkImport}}
func (Context) PbField2GoType ¶
func (c Context) PbField2GoType(field *descriptors.FieldDescriptorProto) *GoType
Field to GoType
func (Context) PbType2GoType ¶
func (c Context) PbType2GoType(pbType descriptors.ProtoType) *GoType
ProtoType to GoType
type GoFormatter ¶
func NewGoFormatter ¶
func NewGoFormatter(ctx *goku.Context) *GoFormatter
func (*GoFormatter) Format ¶
func (c *GoFormatter) Format() []byte
type GoType ¶
type GoType struct {
// contains filtered or unexported fields
}
func (*GoType) FormatPipeline ¶
implemented helper.FormatPipeline
func (*GoType) SetPackage ¶
func (*GoType) SetPipeline ¶
implemented helper.SetPipeline
func (*GoType) SetPointer ¶
Click to show internal directories.
Click to hide internal directories.