Documentation
¶
Index ¶
- func GetMapDirectory(tmpl string) (dir string)
- func Match(pattern, content string) (string, error)
- func ReadServiceTemplate(name string) ([]byte, error)
- func RegisterInterface(name, content, interfaceTemplate, registerTemplate, importPath string, ...) (data string, err error)
- type Field
- type Options
- func (o *Options) GenerateAttributes(directory string, path string) *Options
- func (o *Options) GenerateCode(tmpl, path string) error
- func (o *Options) GenerateService(name string) error
- func (o *Options) GetFieldsFromDB() error
- func (o *Options) InferDirectoryForService(baseDir, serviceName string) (string, error)
- func (o *Options) ReSetDirectory() *Options
- func (o *Options) ReadCodeTemplates() *Options
- func (o *Options) ReadMetaFields() error
- func (o *Options) Register(registry config.Registry, ...) error
- func (o *Options) SetName(name string) *Options
- type Tmpl
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetMapDirectory ¶
func ReadServiceTemplate ¶ added in v1.5.0
ReadServiceTemplate reads a service template file by name.
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
ServiceName string
// Code attributes - import path
RootPackage string
BizPath string
StorePath string
RequestPath string
ModelPath string
RelativePath string
// Service flags
EnableHTTP bool
EnableGRPC bool
EnableWS bool
WithStore bool
WithMiddleware bool
NoBiz bool
NoRouter bool
NoHandler bool
// Service selection
Service string // Target service name for path inference
// Generate by gorm.gen
Table string
FieldTemplate string
Fields string
MainFields string
UpdatableFields string
MetaFields []*Field
// Migration
TimeStr string
}
func (*Options) GenerateAttributes ¶
func (*Options) GenerateCode ¶
func (*Options) GenerateService ¶ added in v1.5.0
GenerateService generates a new service module with configurable HTTP/gRPC servers and business layers.
func (*Options) GetFieldsFromDB ¶
func (*Options) InferDirectoryForService ¶ added in v1.5.0
InferDirectoryForService infers the target directory based on service name using a three-tier strategy: 1. Discover services from cmd/ directory (e.g., cmd/myapp-apiserver → "apiserver") 2. Smart replacement: replace service name in path if found as a path segment 3. Fallback: construct internal/{service}/{suffix} pattern
Example: InferDirectoryForService("internal/apiserver/model", "admserver") → "internal/admserver/model"
func (*Options) ReSetDirectory ¶
func (*Options) ReadCodeTemplates ¶
func (*Options) ReadMetaFields ¶ added in v1.3.0
type Tmpl ¶
type Tmpl string
const ( TmplCmd Tmpl = "cmd" TmplModel Tmpl = "model" TmplStore Tmpl = "store" TmplRequest Tmpl = "request" TmplBiz Tmpl = "biz" TmplHandler Tmpl = "handler" TmplMiddleware Tmpl = "middleware" TmplJob Tmpl = "job" TmplMigration Tmpl = "migration" TmplSeeder Tmpl = "seeder" TmplService Tmpl = "service" )
Click to show internal directories.
Click to hide internal directories.