parser

package
v0.3.18003 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DIYMethods

type DIYMethods struct {
	BaseStructType string
	MethodName     string

	Methods []*Method
	// contains filtered or unexported fields
}

DIYMethods user Custom methods bind to db base struct

func GetModelMethod

func GetModelMethod(v interface{}, skip int) (method *DIYMethods, err error)

GetModelMethod get diy methods

func (*DIYMethods) LoadMethods

func (m *DIYMethods) LoadMethods() error

LoadMethods ast read file get diy method

func (*DIYMethods) Visit

func (m *DIYMethods) Visit(n ast.Node) (w ast.Visitor)

Visit ast visit function

type InterfaceInfo

type InterfaceInfo struct {
	Name        string
	Doc         string
	Methods     []*Method
	Package     string
	ApplyStruct []string
}

InterfaceInfo ...

func (*InterfaceInfo) MatchStruct

func (i *InterfaceInfo) MatchStruct(name string) bool

MatchStruct ...

type InterfacePath

type InterfacePath struct {
	Name     string
	FullName string
	Files    []string
	Package  string
}

InterfacePath interface path

func GetInterfacePath

func GetInterfacePath(v interface{}) (paths []*InterfacePath, err error)

GetInterfacePath get interface's directory path and all files it contains

type InterfaceSet

type InterfaceSet struct {
	Interfaces []InterfaceInfo
	// contains filtered or unexported fields
}

InterfaceSet ...

func (*InterfaceSet) ParseFile

func (i *InterfaceSet) ParseFile(paths []*InterfacePath, structNames []string) error

ParseFile get interface's info from source file

func (*InterfaceSet) Visit

func (i *InterfaceSet) Visit(n ast.Node) (w ast.Visitor)

Visit ast visit function

type Method

type Method struct {
	Receiver   Param
	MethodName string
	Doc        string
	Params     []Param
	Result     []Param
	Body       string
}

Method Apply to query struct and base struct custom method

func DefaultMethodTableName

func DefaultMethodTableName(structName string) *Method

func (*Method) DocComment

func (m *Method) DocComment() string

DocComment return comment sql add "//" every line

func (Method) FuncSign

func (m Method) FuncSign() string

FuncSign function signature

func (*Method) GetBaseStructTmpl

func (m *Method) GetBaseStructTmpl() string

GetBaseStructTmpl return method bind info string

func (*Method) GetParamInTmpl

func (m *Method) GetParamInTmpl() string

GetParamInTmpl return param list

func (*Method) GetResultParamInTmpl

func (m *Method) GetResultParamInTmpl() string

GetResultParamInTmpl return result list

type Param

type Param struct {
	PkgPath   string // package's path: internalopen/model
	Package   string // package's name: model
	Name      string // param's name: user
	Type      string // param's type: User
	IsArray   bool   // is array or not
	IsPointer bool   // is pointer or not
}

Param parameters in method

func (*Param) Eq

func (p *Param) Eq(q Param) bool

Eq if param equal to another

func (*Param) InMainPkg

func (p *Param) InMainPkg() bool

InMainPkg ...

func (*Param) IsBaseType

func (p *Param) IsBaseType() bool

IsBaseType judge whether the param type is basic type

func (*Param) IsError

func (p *Param) IsError() bool

IsError ...

func (*Param) IsGenM

func (p *Param) IsGenM() bool

IsGenM ...

func (*Param) IsGenRowsAffected

func (p *Param) IsGenRowsAffected() bool

IsGenRowsAffected ...

func (*Param) IsGenT

func (p *Param) IsGenT() bool

IsGenT ...

func (*Param) IsInterface

func (p *Param) IsInterface() bool

IsInterface ...

func (*Param) IsMap

func (p *Param) IsMap() bool

IsMap ...

func (*Param) IsNull

func (p *Param) IsNull() bool

IsNull ...

func (*Param) IsTime

func (p *Param) IsTime() bool

IsTime ...

func (*Param) SetName

func (p *Param) SetName(name string)

SetName ...

func (*Param) TmplString

func (p *Param) TmplString() string

TmplString param to string in tmpl

func (*Param) TypeName

func (p *Param) TypeName() string

TypeName ...

Jump to

Keyboard shortcuts

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