golang

package
Version: v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

golang plugin

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsGoKeyword

func IsGoKeyword(s string) bool

func IsGoPredeclaredIdentifier

func IsGoPredeclaredIdentifier(s string) bool

func Throws

func Throws(err error)

Types

type Context

type Context struct {
	*goku.Context
	// contains filtered or unexported fields
}

golang 对context提供的处理函数集合 其他基于 golang 的插件可以继承此类进行扩展

func NewContext

func NewContext(ctx *goku.Context) *Context

func (Context) FileGoPackage

func (c Context) FileGoPackage(file *descriptors.FileDescriptorProto) *GoPackage

File to GoPackage

func (Context) FuncMap

func (c Context) FuncMap() goku.FuncMap

func (Context) GoComments

func (c Context) GoComments(arg interface{}) string

GoComments returns golang style comments string

supported arg:
- string
- []string
- descriptors.DescriptorCommon
- descriptors.SourceCodeInfo_Location

func (Context) GoImport

func (c Context) GoImport(arg interface{}) string

GoImport returns golang style import line string.

func (Context) GoImportDependency

func (c Context) GoImportDependency(arg interface{}) string

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) GoPackage

func (c Context) GoPackage(value interface{}) *GoPackage

func (Context) GoType

func (c Context) GoType(value interface{}) *GoType

interface To GoType

func (Context) GoTypeBase

func (c Context) GoTypeBase(v interface{}) string

返回基本类型名 []*a.T => T

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

func (Context) RegisterPackage

func (c Context) RegisterPackage(pkg string, name string) *GoPackage

type GoFormatter

type GoFormatter struct {
	*goku.Context
	// contains filtered or unexported fields
}

func NewGoFormatter

func NewGoFormatter(ctx *goku.Context) *GoFormatter

func (*GoFormatter) Format

func (c *GoFormatter) Format() []byte

type GoPackage

type GoPackage struct {
	Name       string // 包 别名
	ImportPath string // 包 全路径
}

func GetGoPackageByName

func GetGoPackageByName(name string) *GoPackage

func GetGoPackageByPath

func GetGoPackageByPath(importPath string) *GoPackage

func RegisterPackage

func RegisterPackage(pkg string, name string) *GoPackage

func (GoPackage) Import

func (p GoPackage) Import() string

func (GoPackage) String

func (p GoPackage) String() string

type GoType

type GoType struct {
	// contains filtered or unexported fields
}

func (*GoType) Copy

func (t *GoType) Copy() *GoType

func (*GoType) FormatPipeline

func (t *GoType) FormatPipeline(args helper.Args) (string, error)

implemented helper.FormatPipeline

func (*GoType) Import

func (t *GoType) Import() string

func (*GoType) Name

func (t *GoType) Name() string

func (*GoType) Package

func (t *GoType) Package() *GoPackage

func (*GoType) SetField

func (t *GoType) SetField(field string, value interface{}) *GoType

func (*GoType) SetPackage

func (t *GoType) SetPackage(value interface{}) *GoType

func (*GoType) SetPipeline

func (t *GoType) SetPipeline(field string, value interface{}) interface{}

implemented helper.SetPipeline

func (*GoType) SetPointer

func (t *GoType) SetPointer(value interface{}) *GoType

func (*GoType) String

func (t *GoType) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL