generator

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetMapDirectory

func GetMapDirectory(tmpl string) (dir string)

func Match added in v1.2.7

func Match(pattern, content string) (string, error)

func RegisterInterface

func RegisterInterface(name, content, interfaceTemplate, registerTemplate, importPath string) (data string, err error)

Types

type Field added in v1.3.0

type Field struct {
	Name             string
	Type             string
	ColumnName       string
	ColumnComment    string
	MultilineComment bool
	Tag              genField.Tag
	GORMTag          genField.GormTag
	CustomGenType    string
	Relation         *genField.Relation
}

Field user input structures

type Options

type Options struct {
	// Code template
	Name              string
	Description       string
	FilePath          string
	Directory         string
	CodeTemplate      string
	InterfaceTemplate string
	RegisterTemplate  string

	// Code attributes - variable
	PackageName        string
	StructName         string
	StructNamePlural   string
	VariableName       string
	VariableNameSnake  string
	VariableNamePlural string
	TableName          string
	ModelName          string

	// Code attributes - import path
	RootPackage  string
	BizPath      string
	StorePath    string
	RequestPath  string
	ModelPath    string
	RelativePath string

	// Generate by gorm.gen
	Table           string
	FieldTemplate   string
	Fields          string
	MainFields      string
	UpdatableFields string
	MetaFields      []*Field

	// Migration
	TimeStr string
}

func (*Options) GenerateAttributes

func (o *Options) GenerateAttributes(directory string, path string) *Options

func (*Options) GenerateCode

func (o *Options) GenerateCode(tmpl, path string) error

func (*Options) GetFieldsFromDB

func (o *Options) GetFieldsFromDB() error

func (*Options) ReSetDirectory

func (o *Options) ReSetDirectory() *Options

func (*Options) ReadCodeTemplates

func (o *Options) ReadCodeTemplates() *Options

func (*Options) ReadMetaFields added in v1.3.0

func (o *Options) ReadMetaFields() error

func (*Options) Register

func (o *Options) Register(registry config.Registry, interfaceTemplate, registerTemplate, importPath string) error

func (*Options) SetName

func (o *Options) SetName(name string) *Options

type Tmpl

type Tmpl string
const (
	TmplCmd        Tmpl = "cmd"
	TmplModel      Tmpl = "model"
	TmplStore      Tmpl = "store"
	TmplRequest    Tmpl = "request"
	TmplBiz        Tmpl = "biz"
	TmplController Tmpl = "controller"
	TmplMiddleware Tmpl = "middleware"
	TmplJob        Tmpl = "job"
	TmplMigration  Tmpl = "migration"
	TmplSeeder     Tmpl = "seeder"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳