Documentation ¶
Index ¶
- func EscapeColumnName(s string) string
- func SingularizeIdentifier(in Inflector, s string) string
- type ArgType
- type DefaultInflector
- type Field
- type Index
- type InflectRule
- type Inflector
- type RuleInflector
- type Type
- type TypeLoader
- func (tl *TypeLoader) LoadColumns(args *ArgType, typeTpl *Type) error
- func (tl *TypeLoader) LoadCustomTypes(path string) error
- func (tl *TypeLoader) LoadIndexColumns(args *ArgType, ixTpl *Index) error
- func (tl *TypeLoader) LoadIndexes(args *ArgType, tableMap map[string]*Type) (map[string]*Index, error)
- func (tl *TypeLoader) LoadSchema(args *ArgType) (map[string]*Type, map[string]*Index, error)
- func (tl *TypeLoader) LoadTable(args *ArgType) (map[string]*Type, error)
- func (tl *TypeLoader) LoadTableIndexes(args *ArgType, typeTpl *Type, ixMap map[string]*Index) error
- func (tl *TypeLoader) Mask() string
- func (tl *TypeLoader) NthParam(i int) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EscapeColumnName ¶
EscapeColumnName will escape a column name if using reserved keyword as column name, returning it in surrounded backquotes.
func SingularizeIdentifier ¶
SinguralizeIdentifier will singularize a identifier, returning it in CamelCase.
Types ¶
type ArgType ¶
type ArgType struct { // Project is the GCP project string Project string // Instance is the instance string Instance string // Database is the database string Database string // CustomTypesFile is the path for custom table field type definition file (xx.yml) CustomTypesFile string // Out is the output path. If Out is a file, then that will be used as the // path. If Out is a directory, then the output file will be // Out/<$CWD>.yo.go Out string // Suffix is the output suffix for filenames. Suffix string // SingleFile when toggled changes behavior so that output is to one f ile. SingleFile bool // Package is the name used to generate package headers. If not specified, // the name of the output directory will be used instead. Package string // CustomTypePackage is the Go package name to use for unknown types. CustomTypePackage string // IgnoreFields allows the user to specify field names which should not be // handled by yo in the generated code. IgnoreFields []string // IgnoreTables allows the user to specify table names which should not be // handled by yo in the generated code. IgnoreTables []string // TemplatePath is the path to use the user supplied templates instead of // the built in versions. TemplatePath string // Tags is the list of build tags to add to generated Go files. Tags string Path string Filename string // DDLFilepath is the filepath of the ddl file. DDLFilepath string // FromDDL indicates generating from ddl flie or not. FromDDL bool // InflectionRuleFile is custom inflection rule file. InflectionRuleFile string }
ArgType is the type that specifies the command line arguments.
type DefaultInflector ¶
type DefaultInflector struct{}
func (*DefaultInflector) Pluralize ¶
func (i *DefaultInflector) Pluralize(s string) string
func (*DefaultInflector) Singularize ¶
func (i *DefaultInflector) Singularize(s string) string
type Field ¶
type Field struct { Name string Type string CustomType string NilType string Len int Col *models.Column }
Field contains field information.
type Index ¶
type Index struct { FuncName string Schema string Type *Type Fields []*Field StoringFields []*Field NullableFields []*Field Index *models.Index }
Index is a template item for a index into a table.
type InflectRule ¶
type Inflector ¶
func NewInflector ¶
type RuleInflector ¶
type RuleInflector struct{}
func (*RuleInflector) Pluralize ¶
func (i *RuleInflector) Pluralize(s string) string
func (*RuleInflector) Singularize ¶
func (i *RuleInflector) Singularize(s string) string
type Type ¶
type Type struct { Name string Schema string PrimaryKey *Field PrimaryKeyFields []*Field Fields []*Field Table *models.Table Indexes []*Index }
Type is a template item for a type.
type TypeLoader ¶
type TypeLoader struct { CustomTypes *models.CustomTypes // contains filtered or unexported fields }
TypeLoader provides a common Loader implementation used by the built in schema/query loaders.
func NewTypeLoader ¶
func NewTypeLoader(l loaderImpl, i Inflector) *TypeLoader
func (*TypeLoader) LoadColumns ¶
func (tl *TypeLoader) LoadColumns(args *ArgType, typeTpl *Type) error
LoadColumns loads schema table/view columns.
func (*TypeLoader) LoadCustomTypes ¶
func (tl *TypeLoader) LoadCustomTypes(path string) error
LoadCustomTypes loads custom type definition from yml file
func (*TypeLoader) LoadIndexColumns ¶
func (tl *TypeLoader) LoadIndexColumns(args *ArgType, ixTpl *Index) error
LoadIndexColumns loads the index column information.
func (*TypeLoader) LoadIndexes ¶
func (tl *TypeLoader) LoadIndexes(args *ArgType, tableMap map[string]*Type) (map[string]*Index, error)
LoadIndexes loads schema index definitions.
func (*TypeLoader) LoadSchema ¶
LoadSchema loads schema definitions.
func (*TypeLoader) LoadTable ¶
func (tl *TypeLoader) LoadTable(args *ArgType) (map[string]*Type, error)
LoadTable loads a schema table/view definition.
func (*TypeLoader) LoadTableIndexes ¶
LoadTableIndexes loads schema index definitions per table.
func (*TypeLoader) NthParam ¶
func (tl *TypeLoader) NthParam(i int) string
NthParam satisifies Loader's NthParam.