tmpl

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoopTemplate = `` /* 1035-byte string literal not displayed */

)

Variables

This section is empty.

Functions

func Generate

func Generate(writer io.Writer, data TemplateData, templateContent string)

Generate will populate the buffer with generated code using the supplied type and template

Types

type Field

type Field struct {
	Name         string
	Type         string
	NonArrayType string
	Tags         map[string]string

	Fields []Field
}

Field ...

func GetFields

func GetFields(file *ast.File, desiredStruct string) []Field

GetFields will extract a slice of fields from the supplied AST

func (Field) String

func (f Field) String() string

String implements the stringer interface

type Method

type Method struct {
	Name    string
	Params  []MethodField
	Results []MethodField
}

Method defines the methods defined in an interface

func GetMethods

func GetMethods(file *ast.File, typeName string) []Method

GetMethods will extract a slice of funcs from the supplied AST

func (Method) String

func (f Method) String() string

String implements the stringer interface

type MethodField

type MethodField struct {
	Names []string
	Type  string
}

MethodField defines the input params / output results of a method

type TemplateData

type TemplateData struct {
	TypeName     string
	PackageName  string
	TemplateFile string
	OutputFile   string

	Fields  []Field
	Extras  []string
	Methods []Method
}

TemplateData is the data structure passed to the template engine

Jump to

Keyboard shortcuts

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