templates

package
v0.0.0-...-2d69983 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EnumBase = []CodeTemplate{
	{Name: "Invalid", Raw: typeError},
	{Name: "NameToValue", Raw: nameToValueRaw},
	{Name: "ValueToName", Raw: valueToNameRaw},
	{Name: "String", Raw: stringRaw},
	{Name: "Validate", Raw: validateRaw},
	{Name: "MarshalJSON", Raw: marshalJSONRaw},
	{Name: "UnmarshalJSON", Raw: unmarshalJSONRaw},
	{Name: "Value", Raw: rowValueRaw},
	{Name: "Scan", Raw: rowScanRaw},
}
View Source
var FileBase = CodeTemplate{Name: "base", Raw: baseRaw}
View Source
var Spare = map[string]CodeTemplate{
	"NameToValue": {Name: "NameToValue", Raw: nameToValueSpareRaw},
	"ValueToName": {Name: "ValueToName", Raw: valueToNameSpareRaw},
}

Functions

func OpenTemplate

func OpenTemplate(templatePath string) (*template.Template, error)

Types

type Analysis

type Analysis struct {
	Command     string
	PackageName string
	Types       map[string]TypeSpec
}

func (*Analysis) GenerateByTemplate

func (analysis *Analysis) GenerateByTemplate(merge bool) map[string][]byte

type CodeTemplate

type CodeTemplate struct {
	Name   string
	Raw    string
	Parsed *template.Template
}

type Field

type Field struct {
	Name  string
	FType string
	Tags  map[string]string
}

type ModelSpec

type ModelSpec struct {
	Package    string
	TypeName   string
	TypeString string
	Fields     []Field
}

func FigureOut

func FigureOut(spec *parser.StructureSpec) (_ *ModelSpec, err error)

func (*ModelSpec) Exec

func (spec *ModelSpec) Exec(tmpl *template.Template) (string, error)

type TransformRule

type TransformRule string
var (
	TransformRuleSnake TransformRule = "snake"
	TransformRuleKebab TransformRule = "kebab"
	TransformRuleSpace TransformRule = "space"
	TransformRuleNone  TransformRule = "none"
)

func (TransformRule) Transform

func (rule TransformRule) Transform(src string) string

func (TransformRule) TransformValues

func (rule TransformRule) TransformValues(typeName string, values []string, keepTPrefix bool) []TypeValue

func (TransformRule) Validate

func (rule TransformRule) Validate() error

Validate is an implementation of Validatable interface.

type TypeSpec

type TypeSpec struct {
	TypeName    string
	Values      []TypeValue
	ExcludeList map[string]bool
}

type TypeValue

type TypeValue struct {
	Name string
	Str  string
}

Jump to

Keyboard shortcuts

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