tpls

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: 0BSD Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Params = func() params {
	m := make(params)
	m["common"] = map[string]any{
		"repo":   *cmds.RepoName,
		"root":   *cmds.DirRoot,
		"api":    *cmds.DirApi,
		"model":  *cmds.DirModel,
		"date":   time.Now().Format("2006-01-02 15:04:05"),
		"noedit": "// Auto generated by OneBD. DO NOT EDIT",
	}
	return m
}

Functions

func Ast2Str

func Ast2Str(decls any) (string, error)

func GoFmt

func GoFmt(fp string)

func GoInit

func GoInit(name string)

func GoModtidy

func GoModtidy()

func NewAstField

func NewAstField(name, typ, tag string) *ast.Field

func NewTsTpl

func NewTsTpl(fPath string) (*simpleTsTemplate, error)

func OpenAbsFile

func OpenAbsFile(p ...string) *os.File

func OpenFile

func OpenFile(p ...string) *os.File

func T

func T(p ...string) *template.Template

Types

type Ast

type Ast struct {
	*ast.File
	// contains filtered or unexported fields
}

func NewAst

func NewAst(fPath string) (*Ast, error)

func NewEmptyAst

func NewEmptyAst(packageName string) *Ast

func NewFileOrEmptyAst

func NewFileOrEmptyAst(fPath string, packageName string) (*Ast, error)

func (*Ast) AddImport

func (a *Ast) AddImport(repo string, tags ...string) error

func (*Ast) AddMethod

func (a *Ast) AddMethod(fc *ast.FuncDecl, reWrite bool) bool

add or replace methods

func (*Ast) AddStruct

func (a *Ast) AddStruct(name string, styp *ast.StructType) error

func (*Ast) AddStructMethods

func (a *Ast) AddStructMethods(name string, fcName string, fc *ast.FuncDecl, reWrite bool)

add or replace struct methods

func (*Ast) AddStructWithFields

func (a *Ast) AddStructWithFields(name string, fields ...*ast.Field) error

func (*Ast) AppendStmtInMethod

func (a *Ast) AppendStmtInMethod(t ast.Stmt, fc *ast.FuncDecl, keywords ...string)

func (*Ast) Dump

func (a *Ast) Dump(fPath string) error

func (*Ast) GetAllStructs

func (a *Ast) GetAllStructs() []*SimpleStruct

func (*Ast) GetMethod

func (a *Ast) GetMethod(fcName string) *ast.FuncDecl

func (*Ast) Inspect

func (a *Ast) Inspect(fn func(ast.Node) bool)

type SimpleStruct

type SimpleStruct struct {
	Name   string
	Fields []*ast.Field
}

Jump to

Keyboard shortcuts

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