Documentation
¶
Index ¶
- func GenerateGORMServices(cfg *config.Config, structMetaData []StructMeta) (err error)
- func GetModulePath(targetDir string) (string, error)
- func GetPreloadMap(structs []StructMeta, cfg *config.Config) map[string][]string
- func Map(data []StructMeta) (m map[string]StructMeta)
- type Field
- type StructMeta
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateGORMServices ¶
func GenerateGORMServices(cfg *config.Config, structMetaData []StructMeta) (err error)
generateServices generates the service.go file
func GetModulePath ¶
Returns the go import path for a given directory targetDir
func GetPreloadMap ¶
func GetPreloadMap(structs []StructMeta, cfg *config.Config) map[string][]string
GetPreloadMap returns a map of struct names to their respective preload fields, including nested relationships.
func Map ¶
func Map(data []StructMeta) (m map[string]StructMeta)
Create a StructMeta map from slice.
Types ¶
type Field ¶
type Field struct {
Name string // Field Exact name
Type string // Full data type for the field
BaseType string // Base type stripped of [] or pointers
Tag string // Unmodified struct tag.
Preload bool // Whether this is a foreignKey or many2many field to preload.
Parent string // Parent struct Name
}
Field contains meta-data for each struct field.
type StructMeta ¶
type StructMeta struct {
Name string // Model name e.g User
PKType string // PKType e.g int, int64 etc
Fields []Field // Fields for struct fields that are builtin(only)
Package string // Package name e.g "github.com/username/module/models"
Skip bool // Skip generating service for this struct
}
StructMeta contains metadata about the struct generated by the go/ast.
func Parse ¶
func Parse(modelPkgs []string) []StructMeta
Parse structs in package pkg and return Struct metadata about them.
Click to show internal directories.
Click to hide internal directories.